Each individual release-command may require some unique configuration for its operation. For example your foundry-release-git-semver-branches could benefit from allowing project integrators to specify the semver branch pattern:
...
"foundry": {
"releaseCommands": [
{ "type": "releaseCommand",
"command": "foundry-release-git-semver-branches" ,
"options": {
"pattern": "release/{version}"
}}
]
}
Now I realised that npm exposes all of its global, local and package contents as environment variables... so enter Nconf.
In your release-commands modules (ie foundry-release-git-semver-branches)...
var pkg = require('../package.json');
var commands = Config.env({
separator: '_',
match: /^npm_package_foundry.*/
})
.get('npm:package:foundry:releaseCommands'),
index = Object.keys(commands)
.find( function (index) {
var item = commands[index]
return (typeof item === 'string' && item === pkg.name)
|| (item.type === 'releaseCommand' && item.command === pkg.name);
}),
options = index && commands[index].options || { pattern: null };
// Define our release process
exports.publish = function (params, cb) {
// Calculate the semver branches (e.g. `1.2.3` -> `1.2.x`, `1.x.x`)
var semver = new SemVer(params.version),
pattern = config.pattern;
if (pattern) {
... // do stuff
}
...
Each individual release-command may require some unique configuration for its operation. For example your
foundry-release-git-semver-branchescould benefit from allowing project integrators to specify the semver branch pattern:Now I realised that npm exposes all of its global, local and package contents as environment variables... so enter Nconf.
In your release-commands modules (ie
foundry-release-git-semver-branches)...