- node 10 较低版本没有测试过,可能存在兼容问题
- git clone https://github.com/likegun/autoCommand
- cd autoCommand
- npm i
- 根据demos.js里的规则编写demos.js
- node share.js
{'demo1': {cwd: 'test',// 命令执行的目录,可以为绝对路径、相对路径,默认为process.cwd()outputColor: 'blue',// 可选颜色请参考https://github.com/chalk/chalk,默认为蓝色clearBeforeOutput: false,// 在输出当前命令的结果前,是否要清空命令行窗口,默认为falsecommands: ['ls',//命令可以是字符串{//如果需要覆盖全局设置,可以用对象指定要覆盖的选项command: 'cat index.js',// cwd: '/test', //命令的选项会覆盖demo的选项outputColor: 'red',//命令的选项会覆盖demo的选项// clearBeforeOutput: false //命令的选项会覆盖demo的选项}]},'demo2': {cwd: 'test',commands: ['ls','cat index.js']}}