UNPKG

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