File tree 1 file changed +22
-1
lines changed
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') {
31
31
// @remove -on-eject-end
32
32
33
33
const jest = require ( 'jest' ) ;
34
+ const execSync = require ( 'child_process' ) . execSync ;
34
35
let argv = process . argv . slice ( 2 ) ;
35
36
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
+
36
55
// Watch unless on CI, in coverage mode, or explicitly running all tests
37
56
if (
38
57
! process . env . CI &&
39
58
argv . indexOf ( '--coverage' ) === - 1 &&
40
59
argv . indexOf ( '--watchAll' ) === - 1
41
60
) {
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' ) ;
43
64
}
44
65
45
66
// @remove -on-eject-begin
You can’t perform that action at this time.
0 commit comments