Skip to content

Commit

Permalink
fix: empty testCommandBeforeRelease by default (#696)
Browse files Browse the repository at this point in the history
Co-authored-by: shipjs <[email protected]>
  • Loading branch information
Eunjae Lee and shipjs authored Mar 6, 2020
1 parent 61f5eee commit 34753b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions packages/shipjs-lib/src/lib/config/defaultConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ export default {
publishCommand: ({ isYarn, tag, defaultCommand, dir }) => defaultCommand,
afterPublish: undefined, // ({ exec, dir, version, releaseTag }) => {}
getTagName: ({ version }) => `v${version}`,
testCommandBeforeRelease: ({ isYarn }) =>
isYarn ? 'yarn test' : 'npm run test',
testCommandBeforeRelease: undefined, // ({ isYarn }) => isYarn ? 'yarn test' : 'npm run test',
appName: undefined,
slackIncomingHook: undefined,
slack: {
Expand Down
7 changes: 2 additions & 5 deletions packages/shipjs/src/step/setup/addShipConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default async ({
dryRun,
}) =>
await runStep({ title: 'Creating ship.config.js' }, async () => {
const { testExists, buildExists } = checkIfScriptsExist({ dir });
const { buildExists } = checkIfScriptsExist({ dir });
const config = {
...(isScoped &&
isPublic && {
Expand All @@ -43,7 +43,6 @@ export default async ({
packagesToPublish,
},
}),
...(!testExists && { testCommandBeforeRelease: () => null }),
...(!buildExists && { buildCommand: () => null }),
};
if (dryRun) {
Expand All @@ -70,10 +69,8 @@ export default async ({
function checkIfScriptsExist({ dir }) {
const filePath = path.resolve(dir, 'package.json');
const json = JSON.parse(fs.readFileSync(filePath).toString());
const { test, build } = json.scripts || {};
const { build } = json.scripts || {};
return {
testExists:
Boolean(test) && test !== 'echo "Error: no test specified" && exit 1',
buildExists: Boolean(build),
};
}
11 changes: 5 additions & 6 deletions website/reference/all-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,16 @@ afterPublish: ({ exec, dir, version, releaseTag }) => { /* do something */ }

## `testCommandBeforeRelease`

*default:*
```js
testCommandBeforeRelease: ({ isYarn }) => isYarn ? 'yarn test' : 'npm run test'
```
*default:* `undefined`

Ship.js runs this command at `shipjs trigger` before publishing the package to make sure if it works correctly.

If you don't have any testing tool and want to skip this step, you can do so like the following:
By default, it's undefined because you may already have a CI service running tests on your GitHub PR.

If you want to run something right before release, you can do so like the following:

```js
testCommandBeforeRelease: () => null
testCommandBeforeRelease: ({ isYarn }) => isYarn ? 'yarn test' : 'npm run test'
```

## `releases`
Expand Down

0 comments on commit 34753b0

Please sign in to comment.