Skip to content
Merged
Changes from 1 commit
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
Next Next commit
add special option -- for npm update command
  • Loading branch information
kdnakt committed Jan 22, 2018
commit aeb81702ab6b34e2f985f7228a6b110d99d7e387
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