In my package.json
file, I have a key/value pair that represents an release candidate value.
{
"name": "my-product",
"version": "1.0.0",
"rc": "1",
...
}
Is there a Gulp plugin that will increment the rc
value for me that I can use in a task? If not how can I increment it?
The [gulp-json-modify plugin][1] works nicely with my requirements. Steps are
Install the plugin
$ npm install --save-dev gulp-json-modify
Then in gulpfile.js
const {src, dest} = require('gulp');
const json = require(gulp-modiffy-json);
const package_json = path.join(path.dirname(__filename),'package.json');
const pkg = JSON.parse(fs.readFileSync(package_json));
const name = pkg.name;
const patch = pkg.patch;
const rc = pkg.rc;
function bumpValue(key, value) {
// var value = Number(patch);
value++;
src(['./package.json'])
.pipe(json({
key: key,
value: value
}))
.pipe(dest('./'));
}
function bumpPatch(cb) {
bumpValue('patch', patch);
cb();
}
exports.bumpPatch = bumpPatch
function bumpRc(cb) {
bumpValue('rc', patch);
cb();
}
exports.bumpRc = bumpRc
[1]: https://www.npmjs.com/package/gulp-json-modify
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.