Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(process): make post-success expect a general command instead of an NPM script #36

Merged
merged 1 commit into from
Apr 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.