publish.js 553 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const tildify = require('tildify');
  3. const chalk = require('chalk');
  4. function publishConsole(args) {
  5. // Display help message if user didn't input any arguments
  6. if (!args._.length) {
  7. return this.call('help', {_: ['publish']});
  8. }
  9. const self = this;
  10. return this.post.publish({
  11. slug: args._.pop(),
  12. layout: args._.length ? args._[0] : this.config.default_layout
  13. }, args.r || args.replace).then(post => {
  14. self.log.info('Published: %s', chalk.magenta(tildify(post.path)));
  15. });
  16. }
  17. module.exports = publishConsole;