Skip to content

Commit

Permalink
fix(prepare): make versionUpdated and beforeCommitChanges undefin…
Browse files Browse the repository at this point in the history
…ed by default (#495)
  • Loading branch information
Eunjae Lee authored Dec 3, 2019
1 parent efb1704 commit d9a4c51
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 23 deletions.
4 changes: 2 additions & 2 deletions packages/shipjs-lib/src/lib/config/defaultConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export default {
conventionalChangelogArgs: '-p angular -i CHANGELOG.md -s',
installCommand: ({ isYarn }) =>
isYarn ? 'yarn install --silent' : 'npm install',
versionUpdated: ({ version, releaseType, dir, exec }) => {},
beforeCommitChanges: ({ nextVersion, releaseType, exec, dir }) => {},
versionUpdated: undefined, // ({ version, releaseType, dir, exec }) => {},
beforeCommitChanges: undefined, // ({ nextVersion, releaseType, exec, dir }) => {},
getStagingBranchName: ({ nextVersion, releaseType }) =>
`releases/v${nextVersion}`,
formatCommitMessage: ({ version, releaseType, mergeStrategy, baseBranch }) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ describe('updateVersion', () => {
const output = [];
mockPrint(print, output);
updateVersion({
config: {},
config: {
versionUpdated: () => {},
},
dryRun: true,
});
expect(output).toMatchInlineSnapshot(`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ describe('updateVersionMonorepo', () => {
mockPrint(print, output);
updateVersionMonorepo({
config: {
versionUpdated: () => {},
monorepo: {
packagesToBump: ['packages/*'],
mainVersionFile: 'lerna.json',
Expand Down
14 changes: 8 additions & 6 deletions packages/shipjs/src/step/prepare/commitChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ export default async ({
print(' |');
return;
}
await beforeCommitChanges({
nextVersion,
releaseType,
exec: wrapExecWithDir(dir),
dir,
});
if (beforeCommitChanges) {
await beforeCommitChanges({
nextVersion,
releaseType,
exec: wrapExecWithDir(dir),
dir,
});
}
const filePath = tempWrite.sync(message);
run({ command: 'git add .', dir });
run({ command: `git commit --file=${filePath}`, dir });
Expand Down
18 changes: 11 additions & 7 deletions packages/shipjs/src/step/prepare/updateVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ export default async ({ config, nextVersion, releaseType, dir, dryRun }) =>
const { versionUpdated } = config;
if (dryRun) {
print(`-> ${info('package.json')}`);
print(`-> execute ${info('versionUpdated()')} callback.`);
if (versionUpdated) {
print(`-> execute ${info('versionUpdated()')} callback.`);
}
return;
}
updateVersion({ nextVersion, dir });
await versionUpdated({
version: nextVersion,
releaseType,
dir,
exec: wrapExecWithDir(dir),
});
if (versionUpdated) {
await versionUpdated({
version: nextVersion,
releaseType,
dir,
exec: wrapExecWithDir(dir),
});
}
});
18 changes: 11 additions & 7 deletions packages/shipjs/src/step/prepare/updateVersionMonorepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export default async ({ config, nextVersion, releaseType, dir, dryRun }) =>
packageList.forEach(packageDir =>
print(`-> ${info(`${packageDir}/package.json`)}`)
);
print(`-> execute ${info('versionUpdated()')} callback.`);
if (versionUpdated) {
print(`-> execute ${info('versionUpdated()')} callback.`);
}
return;
}

Expand All @@ -28,11 +30,13 @@ export default async ({ config, nextVersion, releaseType, dir, dryRun }) =>
print(`-> ${info(`${packageDir}/package.json`)}`);
updateVersion({ nextVersion, dir: packageDir });
});
await versionUpdated({
version: nextVersion,
releaseType,
dir,
exec: wrapExecWithDir(dir),
});
if (versionUpdated) {
await versionUpdated({
version: nextVersion,
releaseType,
dir,
exec: wrapExecWithDir(dir),
});
}
}
);

0 comments on commit d9a4c51

Please sign in to comment.