Skip to content

Commit

Permalink
Merge pull request #36 from leonardoanalista/fix/post-success-without…
Browse files Browse the repository at this point in the history
…-version-arg

feat(process): make post-success expect a general command instead of an NPM script
  • Loading branch information
uglow authored Apr 14, 2017
2 parents fd5b08b + 226de45 commit d1041c0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
6 changes: 3 additions & 3 deletions spec/system.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});


Expand Down
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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');
}
});
4 changes: 2 additions & 2 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -21,7 +21,7 @@ module.exports = {
helpers,
isReleaseNecessary,
parseRawCommit,
runScript,
runPreCommitScript,
validateBranch,
whatBump,
writeChangelog,
Expand Down
File renamed without changes.

0 comments on commit d1041c0

Please sign in to comment.