Skip to content

Commit

Permalink
Fix npm update command for snapshot summary (#5376)
Browse files Browse the repository at this point in the history
* add special option -- for npm update command

* Update CHANGELOG.md
  • Loading branch information
kdnakt authored and cpojer committed Jan 24, 2018
1 parent a10288f commit 4080d98
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
([#5353](https://github.com/facebook/jest/pull/5353))
* `[expect]` Support class instances in `.toHaveProperty()` matcher.
([#5367](https://github.com/facebook/jest/pull/5367))
* `[jest-cli]` Fix npm update command for snapshot summary.
([#5376](https://github.com/facebook/jest/pull/5376))

## jest 22.1.4

Expand Down
13 changes: 8 additions & 5 deletions packages/jest-cli/src/reporters/summary_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,22 @@ export default class SummaryReporter extends BaseReporter {
let updateCommand;
const event = process.env.npm_lifecycle_event;
const prefix = NPM_EVENTS.has(event) ? '' : 'run ';
const client =
const isYarn =
typeof process.env.npm_config_user_agent === 'string' &&
process.env.npm_config_user_agent.match('yarn') !== null
? 'yarn'
: 'npm';
process.env.npm_config_user_agent.match('yarn') !== null;
const client = isYarn ? 'yarn' : 'npm';
const scriptUsesJest =
typeof process.env.npm_lifecycle_script === 'string' &&
process.env.npm_lifecycle_script.indexOf('jest') !== -1;

if (globalConfig.watch) {
updateCommand = 'press `u`';
} else if (event && scriptUsesJest) {
updateCommand = `run \`${client + ' ' + prefix + event} -u\``;
updateCommand = `run \`${client +
' ' +
prefix +
event +
(isYarn ? '' : ' --')} -u\``;
} else {
updateCommand = 're-run jest with `-u`';
}
Expand Down

0 comments on commit 4080d98

Please sign in to comment.