how I need to set up package.json to check if build success then add and commit changes to git?
Current build:
"build": "react-scripts build"
how I need to set up package.json to check if build success then add and commit changes to git?
Current build:
"build": "react-scripts build"
Here the answer:
"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] })\""
}
Running like:
$ npm run build-and-commit -- "commit message"
or:
$ yarn build-and-commit -- "commit message"
Full answer here: Pass git commit message to npm script and append to predefined string
Tnx to RobC