publish.js 531 B

1234567891011121314151617181920
  1. 'use strict';
  2. const tildify = require('tildify');
  3. const { magenta } = 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. return this.post.publish({
  10. slug: args._.pop(),
  11. layout: args._.length ? args._[0] : this.config.default_layout
  12. }, args.r || args.replace).then(post => {
  13. this.log.info('Published: %s', magenta(tildify(post.path)));
  14. });
  15. }
  16. module.exports = publishConsole;