shelljs

作者: JaneMinHa | 来源:发表于2020-01-15 10:15 被阅读0次

安装

根目录新建package.json文件
npm install shelljs --save 

使用

1、根目录新建shell.js

const shell = require('shelljs');
const path = require('path');
 shell.cd(path.resolve(__dirname, `../${dirName}`));
shell.exec('git checkout -b branchName origin/branchName');
shell.exec('git pull');
shell.exec('git log -p');

2、package.json添加scripts

{
  "name": "shellTest",
  "version": "1.0.0",
  "scripts": {
    "shell": "node shell.js"
  },
  "dependencies": {
    "shelljs": "^0.8.3"
  }
}

3、npm run shell

相关文章

网友评论

      本文标题:shelljs

      本文链接:https://www.haomeiwen.com/subject/tbzzactx.html