File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212
1313var spawn = require ( 'cross-spawn' ) ;
1414var script = process . argv [ 2 ] ;
15- var args = process . argv . slice ( 3 ) ;
15+ var getArgs = require ( '../scripts/utils/getSubscriptArgs' ) ;
1616
1717switch ( script ) {
1818 case 'build' :
1919 case 'eject' :
2020 case 'start' :
2121 case 'test' :
22- var result = spawn . sync (
23- 'node' ,
24- [ require . resolve ( '../scripts/' + script ) ] . concat ( args ) ,
25- { stdio : 'inherit' }
26- ) ;
22+ var scriptFilename = require . resolve ( '../scripts/' + script ) ;
23+ var result = spawn . sync ( 'node' , getArgs ( scriptFilename ) , {
24+ stdio : 'inherit' ,
25+ } ) ;
2726 if ( result . signal ) {
2827 if ( result . signal === 'SIGKILL' ) {
2928 console . log (
Original file line number Diff line number Diff line change @@ -13,4 +13,5 @@ const babelJest = require('babel-jest');
1313module . exports = babelJest . createTransformer ( {
1414 presets : [ require . resolve ( 'babel-preset-react-app' ) ] ,
1515 babelrc : false ,
16+ sourceMaps : process . env . REACT_APP_DEBUG_JEST ? 'inline' : false ,
1617} ) ;
Original file line number Diff line number Diff line change 88 * of patent rights can be found in the PATENTS file in the same directory.
99 */
1010// @remove -on-eject-end
11+
12+ /**
13+ * Greetings! If you are here attempting to start a debugging session, please
14+ * ensure that your debugger of choice is configured to enable source maps,
15+ * otherwise your code may appear mangled by babel!
16+ */
1117'use strict' ;
1218
19+ var debugArgs = require ( './utils/debugArgs' ) ;
20+
1321process . env . NODE_ENV = 'test' ;
1422process . env . PUBLIC_URL = '' ;
1523
@@ -27,13 +35,23 @@ process.on('unhandledRejection', err => {
2735require ( 'dotenv' ) . config ( { silent : true } ) ;
2836
2937const jest = require ( 'jest' ) ;
30- const argv = process . argv . slice ( 2 ) ;
38+ let argv = process . argv . slice ( 2 ) ;
39+ const isDebug = ! ! process . env . REACT_APP_DEBUG_JEST ;
40+ const isRunInBand = argv . indexOf ( '--runInBand' ) > - 1 || argv . indexOf ( '-i' ) > - 1 ;
3141
3242// Watch unless on CI or in coverage mode
3343if ( ! process . env . CI && argv . indexOf ( '--coverage' ) < 0 ) {
3444 argv . push ( '--watch' ) ;
3545}
3646
47+ // Force debug into single worker
48+ if ( isDebug ) {
49+ if ( ! isRunInBand ) {
50+ argv . push ( '--runInBand' ) ;
51+ }
52+ argv = debugArgs . removeFrom ( argv ) ;
53+ }
54+
3755// @remove -on-eject-begin
3856// This is not necessary after eject because we embed config into package.json.
3957const createJestConfig = require ( './utils/createJestConfig' ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) 2015-present, Facebook, Inc.
3+ * All rights reserved.
4+ *
5+ * This source code is licensed under the BSD-style license found in the
6+ * LICENSE file in the root directory of this source tree. An additional grant
7+ * of patent rights can be found in the PATENTS file in the same directory.
8+ */
9+ 'use strict' ;
10+
11+ const DEBUG_FLAGS = [
12+ / ^ d e b u g $ / ,
13+ / ^ - - d e b u g $ / ,
14+ / ^ - - d e b u g - b r k ( = \d + ) ? $ / ,
15+ / ^ - - i n s p e c t $ / ,
16+ / ^ - - i n s p e c t - b r k ( = \d + ) ? $ / ,
17+ ] ;
18+
19+ module . exports = {
20+ _match : function _matchDebugFlags ( args , onMatch ) {
21+ for ( var i in args ) {
22+ if ( args . hasOwnProperty ( i ) ) {
23+ for ( var j in DEBUG_FLAGS ) {
24+ if ( DEBUG_FLAGS . hasOwnProperty ( j ) ) {
25+ if ( args [ i ] . match ( DEBUG_FLAGS [ j ] ) ) {
26+ onMatch ( args [ i ] ) ;
27+ }
28+ }
29+ }
30+ }
31+ }
32+ } ,
33+ getFrom : function getDebugFlags ( args ) {
34+ var matches = [ ] ;
35+ this . _match ( args , function addMatch ( arg ) {
36+ matches . push ( arg ) ;
37+ } ) ;
38+ return matches . length ? matches : null ;
39+ } ,
40+ removeFrom : function removeDebugFlags ( args ) {
41+ var matches = this . getFrom ( args ) || [ ] ;
42+ return args . filter ( function isNotDebugArg ( arg ) {
43+ return ! matches . some ( function isPresent ( debugArg ) {
44+ return arg === debugArg ;
45+ } ) ;
46+ } ) ;
47+ } ,
48+ } ;
Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) 2015-present, Facebook, Inc.
3+ * All rights reserved.
4+ *
5+ * This source code is licensed under the BSD-style license found in the
6+ * LICENSE file in the root directory of this source tree. An additional grant
7+ * of patent rights can be found in the PATENTS file in the same directory.
8+ */
9+ 'use strict' ;
10+
11+ var debugArgs = require ( '../utils/debugArgs' ) ;
12+
13+ module . exports = function getSubscriptArgs ( scriptFilename ) {
14+ var args = process . argv . slice ( 3 ) ;
15+ var passedDebugArgs ;
16+ var nonDebugArgs ;
17+ args . unshift ( scriptFilename ) ;
18+ passedDebugArgs = debugArgs . getFrom ( args ) ;
19+ if ( passedDebugArgs ) {
20+ process . env . REACT_APP_DEBUG_JEST = 'true' ; // :eyes: side-effect
21+ nonDebugArgs = debugArgs . removeFrom ( args ) ;
22+ args = passedDebugArgs . concat ( nonDebugArgs ) ;
23+ }
24+ return args ;
25+ } ;
You can’t perform that action at this time.
0 commit comments