From da75cc6ee0adcf047913816d005f111c717bc74b Mon Sep 17 00:00:00 2001 From: Nicolas Guilhaudin Date: Mon, 25 Feb 2019 18:38:44 +0100 Subject: [PATCH] feat(app): add ci parameter users can specify whether or not CI scripts should be run --- src/index.js | 3 ++- src/lib/addFilesAndCreateTag.js | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 41647e3..4c3f935 100755 --- a/src/index.js +++ b/src/index.js @@ -29,6 +29,7 @@ if (!pkg.name || !oldVersion) { program .version(oldVersion) + .option('--ci', 'Do not skip Continuous Integration in CI environment. This remove "[ci skip] ***NO_CI***" from commit message') .option('-d, --dryrun', 'No changes to workspace. Stops after changelog is printed.') .option('--pre-commit [npm-script]', 'Pre-commit hook. Pass the name of the npm script to run. It will run like this: npm run [pre-commit]') .option('--post-success [command]', 'Post-success hook (after git push completes successfully). Pass a command to run as the argument. Eg: --post-success "npm publish"') @@ -134,7 +135,7 @@ function(err, results) { // ### STEP 9 - Tag and push (DESTRUCTIVE OPERATION) if (!program.dryrun) { - lib.addFilesAndCreateTag(version, program.mockPush); + lib.addFilesAndCreateTag(version, program.mockPush, program.ci); } else { log.info('>>> Skipping git push'); } diff --git a/src/lib/addFilesAndCreateTag.js b/src/lib/addFilesAndCreateTag.js index aa16234..f9b3a31 100644 --- a/src/lib/addFilesAndCreateTag.js +++ b/src/lib/addFilesAndCreateTag.js @@ -3,7 +3,7 @@ const terminateProcess = require('./helpers').terminateProcess; const shell = require('shelljs'); const log = require('./log'); -module.exports = function addFilesAndCreateTag(newVersion, mockPush) { +module.exports = function addFilesAndCreateTag(newVersion, mockPush, ci) { let code; // ###### Add edited files to git ##### log.info('>>> About to add and commit package.json and CHANGELOG...'); @@ -11,7 +11,13 @@ module.exports = function addFilesAndCreateTag(newVersion, mockPush) { terminateProcess(code); // ###### Commit files ##### - code = shell.exec('git commit -m "chore(release): ' + newVersion + ' [ci skip] ***NO_CI***"').code; + let commitMessage = 'git commit -m "chore(release): ' + newVersion; + if (!ci) { + commitMessage+= ' [ci skip] ***NO_CI***"'; + } else { + commitMessage+= '"'; + } + code = shell.exec(commitMessage).code; terminateProcess(code); // ###### TAG NEW VERSION #####