Skip to content

Commit

Permalink
print version ending in -dev when running a local Jest clone (jestjs#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeysal authored and captain-yossarian committed Jul 18, 2019
1 parent 19ad8c7 commit 1f449ac
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- `[jest-haste-map]` [**BREAKING**] Remove name from hash in `HasteMap.getCacheFilePath` ([#7218](https://github.com/facebook/jest/pull/7218))
- `[babel-preset-jest]` [**BREAKING**] Export a function instead of an object for Babel 7 compatibility ([#7203](https://github.com/facebook/jest/pull/7203))
- `[jest-haste-map]` [**BREAKING**] Expose relative paths when getting the file iterator ([#7321](https://github.com/facebook/jest/pull/7321))
- `[jest-cli]` Print version ending in `-dev` when running a local Jest clone
- `[jest-cli]` Add Support for `globalSetup` and `globalTeardown` in projects ([#6865](https://github.com/facebook/jest/pull/6865))
- `[jest-runtime]` Add `extraGlobals` to config to load extra global variables into the execution vm ([#7454](https://github.com/facebook/jest/pull/7454))
- `[jest-util]` Export `specialChars` containing Unicode characters and ANSI escapes for console output ([#7532](https://github.com/facebook/jest/pull/7532))
Expand Down
2 changes: 1 addition & 1 deletion e2e/__tests__/version.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test('works with jest.config.js', () => {
});

const {status, stdout, stderr} = runJest(DIR, ['--version']);
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*$/);
expect(stdout).toMatch(/\d{2}\.\d{1,2}\.\d{1,2}[\-\S]*-dev$/);
// Only version gets printed and nothing else
expect(stdout.split(/\n/)).toHaveLength(1);
expect(stderr).toBe('');
Expand Down
7 changes: 7 additions & 0 deletions packages/jest-cli/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {AggregatedResult} from 'types/TestResult';
import type {Argv} from 'types/Argv';
import type {GlobalConfig, Path} from 'types/Config';

import path from 'path';
import {Console, clearLine, createDirectory} from 'jest-util';
import {validateCLIOptions} from 'jest-validate';
import {readConfigs, deprecationEntries} from 'jest-config';
Expand All @@ -22,6 +23,7 @@ import getChangedFilesPromise from '../getChangedFilesPromise';
import {formatHandleErrors} from '../collectHandles';
import handleDeprecationWarnings from '../lib/handle_deprecation_warnings';
import {print as preRunMessagePrint} from '../preRunMessage';
import {getVersion} from '../jest';
import runJest from '../runJest';
import Runtime from 'jest-runtime';
import TestWatcher from '../TestWatcher';
Expand Down Expand Up @@ -176,9 +178,14 @@ const readResultsAndExit = (
};

export const buildArgv = (maybeArgv: ?Argv, project: ?Path) => {
const version =
getVersion() +
(__dirname.includes(`packages${path.sep}jest-cli`) ? '-dev' : '');

const rawArgv: Argv | string[] = maybeArgv || process.argv.slice(2);
const argv: Argv = yargs(rawArgv)
.usage(args.usage)
.version(version)
.alias('help', 'h')
.options(args.options)
.epilogue(args.docs)
Expand Down

0 comments on commit 1f449ac

Please sign in to comment.