Skip to content

Commit

Permalink
feat(app): add ci parameter
Browse files Browse the repository at this point in the history
users can specify whether or not CI scripts should be run
  • Loading branch information
Nicolas Guilhaudin committed Feb 25, 2019
1 parent 522b239 commit da75cc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"')
Expand Down Expand Up @@ -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');
}
Expand Down
10 changes: 8 additions & 2 deletions src/lib/addFilesAndCreateTag.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@ 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...');
code = shell.exec('git add package.json CHANGELOG.md').code;
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 #####
Expand Down

0 comments on commit da75cc6

Please sign in to comment.