Skip to content

Commit 4080d98

Browse files
kdnaktcpojer
authored andcommitted
Fix npm update command for snapshot summary (#5376)
* add special option -- for npm update command * Update CHANGELOG.md
1 parent a10288f commit 4080d98

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
([#5353](https://github.com/facebook/jest/pull/5353))
1212
* `[expect]` Support class instances in `.toHaveProperty()` matcher.
1313
([#5367](https://github.com/facebook/jest/pull/5367))
14+
* `[jest-cli]` Fix npm update command for snapshot summary.
15+
([#5376](https://github.com/facebook/jest/pull/5376))
1416

1517
## jest 22.1.4
1618

packages/jest-cli/src/reporters/summary_reporter.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,22 @@ export default class SummaryReporter extends BaseReporter {
129129
let updateCommand;
130130
const event = process.env.npm_lifecycle_event;
131131
const prefix = NPM_EVENTS.has(event) ? '' : 'run ';
132-
const client =
132+
const isYarn =
133133
typeof process.env.npm_config_user_agent === 'string' &&
134-
process.env.npm_config_user_agent.match('yarn') !== null
135-
? 'yarn'
136-
: 'npm';
134+
process.env.npm_config_user_agent.match('yarn') !== null;
135+
const client = isYarn ? 'yarn' : 'npm';
137136
const scriptUsesJest =
138137
typeof process.env.npm_lifecycle_script === 'string' &&
139138
process.env.npm_lifecycle_script.indexOf('jest') !== -1;
140139

141140
if (globalConfig.watch) {
142141
updateCommand = 'press `u`';
143142
} else if (event && scriptUsesJest) {
144-
updateCommand = `run \`${client + ' ' + prefix + event} -u\``;
143+
updateCommand = `run \`${client +
144+
' ' +
145+
prefix +
146+
event +
147+
(isYarn ? '' : ' --')} -u\``;
145148
} else {
146149
updateCommand = 're-run jest with `-u`';
147150
}

0 commit comments

Comments
 (0)