migrate.js 761 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const { underline, magenta } = require('chalk');
  3. function migrateConsole(args) {
  4. // Display help message if user didn't input any arguments
  5. if (!args._.length) {
  6. return this.call('help', {_: ['migrate']});
  7. }
  8. const type = args._.shift();
  9. const migrators = this.extend.migrator.list();
  10. if (!migrators[type]) {
  11. let help = '';
  12. help += `${magenta(type)} migrator plugin is not installed.\n\n`;
  13. help += 'Installed migrator plugins:\n';
  14. help += ` ${Object.keys(migrators).join(', ')}\n\n`;
  15. help += `For more help, you can check the online docs: ${underline('https://hexo.io/')}`;
  16. console.log(help);
  17. return;
  18. }
  19. return Reflect.apply(migrators[type], this, [args]);
  20. }
  21. module.exports = migrateConsole;