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

fix: pass releaseTag to afterPublish hook #632

Merged
merged 1 commit into from
Jan 22, 2020
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
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,6 +19,7 @@ describe('runAfterPublish', () => {
Object {
"dir": ".",
"exec": undefined,
"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