You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to up a build number with each build (no matter what else increases!), but unfortunately this seems not to be supported by bumpup (have to set it manually, but why?)
So therefore I wrote a custom setter. This uses another value I defined in package.json called "build"
with each build, this value is increased (just a Number) and appended to the bumped Version
So far this works, but fails when trying to save the newly modified value back to disk, using grunt.file.write.
After looking at the bumpup code, this is what seems to happen:
bumpup reads the file directly from the "package.json" file
and writes the same data back when finished
Of course, any modifications to the package config - done in a setter - are ignored and overwritten! So, I think it would be better if bumpup reads the config from grunt instead from a file, and makes sure it writes the same (current) config back to disk. By this way, setters would have a chance to actually modify something here without being forgotten.
To test my assertion I made the following changes to bumpup:
var meta = grunt.config.get().pkg;
var indentation = grunt.option('indentation') || ' ';
grunt.log.verbose.writeln('Bumping "' + filepath.cyan + '":');
// Update properties with defined setters
Object.keys(setters).forEach(function (key) {
if (!Object.prototype.hasOwnProperty.call(meta, key)) {
return;
}
var newValue;
if (o.normalize && norm[key] != null) {
newValue = norm[key];
} else {
norm[key] = newValue = setters[key](meta[key], releaseType, o, buildMeta);
}
if (newValue != null) {
grunt.config.set("pkg." + key, newValue);
grunt.log.verbose.writeln(grunt.util.repeat(Math.max(16 - key.length, 0), ' ') + key + ' : ' + newValue);
}
});
// Update config property
if (updatePropsMap[filepath]) {
grunt.config.set(updatePropsMap[filepath], meta);
}
// Stringify new metafile and save
if (!grunt.file.write(filepath, JSON.stringify(grunt.config.get().pkg, null, indentation) + (o.newlineEof ? "\n" : ''))) {
grunt.log.warn('Couldn\'t write to "' + filepath + '"');
}
Of course, this is only "quick and dirty", but I think this would be a more flexible solution. An alternative would be an option to bump the build number automatically. Or both ;)
The text was updated successfully, but these errors were encountered:
Hello,
I have the following problem with bumpup:
So far this works, but fails when trying to save the newly modified value back to disk, using grunt.file.write.
After looking at the bumpup code, this is what seems to happen:
Of course, any modifications to the package config - done in a setter - are ignored and overwritten! So, I think it would be better if bumpup reads the config from grunt instead from a file, and makes sure it writes the same (current) config back to disk. By this way, setters would have a chance to actually modify something here without being forgotten.
To test my assertion I made the following changes to bumpup:
Of course, this is only "quick and dirty", but I think this would be a more flexible solution. An alternative would be an option to bump the build number automatically. Or both ;)
The text was updated successfully, but these errors were encountered: