diff --git a/README.md b/README.md index 5ca9dd0..572fb1e 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,8 @@ Of course you can change `corp-release` to any name you like. ## Options * `-d` or `--dryrun`: it runs in non-destructive mode. No alteration should be done in your workspace. -* `--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]`. -* `--post-success [npm-script]`: Post-success hook (after `git push` completes successfully, or in dry-run mode). Pass the name of the npm script to run. It will run like this: `npm run [post-commit]`. If you need more hooks to be implemented please open an issue. +* `--pre-commit [npm-script]`: Pre-commit hook. Pass the name of the npm script to run. It will run like this: `npm run [npm-script]`. +* `--post-success [command]`: Post-success hook (after `git push` completes successfully). Pass a command to run as the argument. Eg: `--post-success "npm publish"`. * `-b [branch]` or `--branch [branch]`: Branch name allowed to run release. Default is `master`. If you want to release from another branch, you need to specify. * `-v` or `--verbose`: it prints extra info such as commit list from last tag and command details. * `--changelogpreset [preset]`: The conventional-changelog preset to use. Default is `angular`. `angular-bitbucket` is available for [BitBucket repositories](https://github.com/uglow/conventional-changelog-angular-bitbucket). Other presets can be installed, e.g: `npm i conventional-changelog-jquery` then pass this flag to the command: `--changelogpreset jquery`. diff --git a/spec/system.spec.js b/spec/system.spec.js index 9d6a1be..48f706f 100644 --- a/spec/system.spec.js +++ b/spec/system.spec.js @@ -351,15 +351,15 @@ describe('corp-semantic-release', function() { expect(out).to.include('and exited with code 128'); expect(out).not.to.include('Skipping git push'); - expect(out).not.to.include('Skipping post-success script'); + expect(out).not.to.include('Skipping post-success command'); }); it('should not run post-success script in dry mode', function() { commitFeat(); - const out = semanticRelease(`--post-success do-publish -d`); + const out = semanticRelease(`--post-success "npm run dopublish" -d`); expect(out).to.include('Skipping git push'); - expect(out).to.include('Skipping post-success script'); + expect(out).to.include('Skipping post-success command'); }); diff --git a/src/index.js b/src/index.js index f317a05..31d97f6 100755 --- a/src/index.js +++ b/src/index.js @@ -124,7 +124,7 @@ function(err, results) { if (program.dryRun) { log.info('>>> Skipping pre-commit script'); } else { - lib.runScript(program.preCommit, 'pre-commit', version); + lib.runPreCommitScript(program.preCommit, 'pre-commit', version); } // ### STEP 9 - Tag and push (DESTRUCTIVE OPERATION) @@ -133,10 +133,11 @@ function(err, results) { // ### STEP 10 - Run after successful push (DESTRUCTIVE OPERATION) if (pushResultCode === 0) { - lib.runScript(program.postSuccess, 'post-success', version); + log.info(`>>> about to run "post-success" command "${program.postSuccess}"`); + shell.exec(program.postSuccess); } } else { log.info('>>> Skipping git push'); - log.info('>>> Skipping post-success script'); + log.info('>>> Skipping post-success command'); } }); diff --git a/src/lib/index.js b/src/lib/index.js index 26a92a0..454a077 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -7,7 +7,7 @@ const getLatestTag = require('./getLatestTag'); const helpers = require('./helpers'); const isReleaseNecessary = require('./isReleaseNecessary'); const parseRawCommit = require('./parseRawCommit'); -const runScript = require('./runScript'); +const runPreCommitScript = require('./runPreCommitScript'); const validateBranch = require('./validateBranch'); const whatBump = require('./whatBump'); const writeChangelog = require('./writeChangelog'); @@ -21,7 +21,7 @@ module.exports = { helpers, isReleaseNecessary, parseRawCommit, - runScript, + runPreCommitScript, validateBranch, whatBump, writeChangelog, diff --git a/src/lib/runScript.js b/src/lib/runPreCommitScript.js similarity index 100% rename from src/lib/runScript.js rename to src/lib/runPreCommitScript.js