File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
packages/react-scripts/scripts Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -31,15 +31,36 @@ if (process.env.SKIP_PREFLIGHT_CHECK !== 'true') {
3131// @remove -on-eject-end
3232
3333const jest = require ( 'jest' ) ;
34+ const execSync = require ( 'child_process' ) . execSync ;
3435let argv = process . argv . slice ( 2 ) ;
3536
37+ function isInGitRepository ( ) {
38+ try {
39+ execSync ( 'git rev-parse --is-inside-work-tree' , { stdio : 'ignore' } ) ;
40+ return true ;
41+ } catch ( e ) {
42+ return false ;
43+ }
44+ }
45+
46+ function isInMercurialRepository ( ) {
47+ try {
48+ execSync ( 'hg --cwd . root' , { stdio : 'ignore' } ) ;
49+ return true ;
50+ } catch ( e ) {
51+ return false ;
52+ }
53+ }
54+
3655// Watch unless on CI, in coverage mode, or explicitly running all tests
3756if (
3857 ! process . env . CI &&
3958 argv . indexOf ( '--coverage' ) === - 1 &&
4059 argv . indexOf ( '--watchAll' ) === - 1
4160) {
42- argv . push ( '--watch' ) ;
61+ // https://github.com/facebook/create-react-app/issues/5210
62+ const hasSourceControl = isInGitRepository ( ) || isInMercurialRepository ( ) ;
63+ argv . push ( hasSourceControl ? '--watch' : '--watchAll' ) ;
4364}
4465
4566// @remove -on-eject-begin
You can’t perform that action at this time.
0 commit comments