npm 运行 构建,如果成功则提交
npm run build and if success then commit
我需要如何设置 package.json 来检查构建是否成功,然后添加并提交对 git 的更改?
当前版本:
"build": "react-scripts build"
这里是答案:
"scripts": {
"build": "react-scripts build",
"build-and-commit": "node -e \"const mssg = process.argv[1]; require('child_process').execSync('npm run build && git add . && git commit -m \\"' + mssg + '\\"', { stdio:[0, 1, 2] })\""
}
运行 喜欢:
$ npm run build-and-commit -- "commit message"
或:
$ yarn build-and-commit -- "commit message"
完整答案在这里:Pass git commit message to npm script and append to predefined string
转 RobC
我需要如何设置 package.json 来检查构建是否成功,然后添加并提交对 git 的更改?
当前版本:
"build": "react-scripts build"
这里是答案:
"scripts": {
"build": "react-scripts build",
"build-and-commit": "node -e \"const mssg = process.argv[1]; require('child_process').execSync('npm run build && git add . && git commit -m \\"' + mssg + '\\"', { stdio:[0, 1, 2] })\""
}
运行 喜欢:
$ npm run build-and-commit -- "commit message"
或:
$ yarn build-and-commit -- "commit message"
完整答案在这里:Pass git commit message to npm script and append to predefined string
转 RobC