Skip to content

Commit

Permalink
fix: pass releaseTag to afterPublish hook
Browse files Browse the repository at this point in the history
  • Loading branch information
shipjs committed Jan 22, 2020
1 parent 89e5d73 commit 1f09d85
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/shipjs-lib/src/lib/config/defaultConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {
buildCommand: ({ isYarn }) => (isYarn ? 'yarn build' : 'npm run build'),
beforePublish: undefined, // ({ exec, dir }) => {}
publishCommand: ({ isYarn, tag, defaultCommand, dir }) => defaultCommand,
afterPublish: undefined, // ({ exec, dir }) => {}
afterPublish: undefined, // ({ exec, dir, version, releaseTag }) => {}
getTagName: ({ version }) => `v${version}`,
testCommandBeforeRelease: ({ isYarn }) =>
isYarn ? 'yarn test' : 'npm run test',
Expand Down
2 changes: 1 addition & 1 deletion packages/shipjs/src/flow/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async function release({ help = false, dir = '.', dryRun = false }) {
runBuild({ isYarn, config, dir, dryRun });
await runBeforePublish({ config, dir, dryRun });
runPublish({ isYarn, config, releaseTag, dir, dryRun });
await runAfterPublish({ version, config, dir, dryRun });
await runAfterPublish({ version, releaseTag, config, dir, dryRun });
const { tagName } = createGitTag({ version, config, dir, dryRun });
gitPush({ tagName, config, dir, dryRun });
await createGitHubRelease({ version, config, dir, dryRun });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe('runAfterPublish', () => {
const afterPublish = jest.fn();
await runAfterPublish({
version: '1.2.3',
releaseTag: 'latest',
config: {
afterPublish,
},
Expand All @@ -18,7 +19,8 @@ describe('runAfterPublish', () => {
Object {
"dir": ".",
"exec": undefined,
"version": "1.2.3",
"releaseTag": "latest",
"version": "1.2.3"
}
`);
});
Expand Down
9 changes: 7 additions & 2 deletions packages/shipjs/src/step/release/runAfterPublish.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import runStep from '../runStep';
import { wrapExecWithDir, print } from '../../util';
import { info } from '../../color';

export default ({ version, config, dir, dryRun }) =>
export default ({ version, releaseTag, config, dir, dryRun }) =>
runStep(
{
title: 'Running "afterPublish" callback.',
Expand All @@ -14,6 +14,11 @@ export default ({ version, config, dir, dryRun }) =>
print(`-> execute ${info('afterPublish()')} callback.`);
return;
}
await config.afterPublish({ exec: wrapExecWithDir(dir), dir, version });
await config.afterPublish({
exec: wrapExecWithDir(dir),
dir,
version,
releaseTag,
});
}
);
2 changes: 1 addition & 1 deletion website/reference/all-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ publishCommand: ({ isYarn, tag, defaultCommand, dir }) => {

```js
// example
afterPublish: ({ exec, dir }) => { /* do something */ }
afterPublish: ({ exec, dir, version, releaseTag }) => { /* do something */ }
```

## `testCommandBeforeRelease`
Expand Down

0 comments on commit 1f09d85

Please sign in to comment.