假设我们想从提示符中重新启动Vorpal应用程序。
如用命令:
重新启动
我尝试过不同的方法,包括执行一个外壳脚本来终止进程,并在没有运气的情况下执行节点app.js
任何小贴士
发布于 2016-03-08 07:50:51
发布于 2016-08-27 03:25:11
我有一个vorpal脚本,它在每次执行命令时重新加载所需的文件。
const vorpal = require('vorpal')();
function genFn(name){
return function(args, callback) {
delete require.cache[require.resolve('./example.js')];
const script = require('./example.js');
script[name](args, callback);
};
}
const commands = {
'listAllRoles' : 'list all roles for development purposes',
};
for(var key in commands){
vorpal
.command(key, commands[key])
.action(genFn(key));
}
vorpal
.delimiter('example')
.show();在example.js中
module.exports.listAllRoles = function(args, callback) {
this.log('bar');
callback();
}https://stackoverflow.com/questions/35854885
复制相似问题