-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
'use strict'; | ||
|
||
const DEBUG_FLAGS = [ | ||
/^debug$/, | ||
/^--debug$/, | ||
/^--debug-brk(=\d+)?$/, | ||
/^--inspect$/, | ||
/^--inspect-brk(=\d+)?$/, | ||
]; | ||
|
||
module.exports = { | ||
_match: function _matchDebugFlags(args, onMatch) { | ||
for (var i in args) { | ||
if (args.hasOwnProperty(i)) { | ||
for (var j in DEBUG_FLAGS) { | ||
if (DEBUG_FLAGS.hasOwnProperty(j)) { | ||
if (args[i].match(DEBUG_FLAGS[j])) { | ||
onMatch(args[i]); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
getFrom: function getDebugFlags(args) { | ||
var matches = []; | ||
this._match(args, function addMatch(arg) { | ||
matches.push(arg); | ||
}); | ||
return matches.length ? matches : null; | ||
}, | ||
removeFrom: function removeDebugFlags(args) { | ||
var matches = this.getFrom(args) || []; | ||
return args.filter(function isNotDebugArg(arg) { | ||
return !matches.some(function isPresent(debugArg) { | ||
return arg === debugArg; | ||
}); | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
*/ | ||
'use strict'; | ||
|
||
var debugArgs = require('../utils/debugArgs'); | ||
|
||
module.exports = function getSubscriptArgs(scriptFilename) { | ||
var args = process.argv.slice(3); | ||
var passedDebugArgs; | ||
var nonDebugArgs; | ||
args.unshift(scriptFilename); | ||
passedDebugArgs = debugArgs.getFrom(args); | ||
if (passedDebugArgs) { | ||
process.env.REACT_APP_DEBUG_JEST = 'true'; // :eyes: side-effect | ||
nonDebugArgs = debugArgs.removeFrom(args); | ||
args = passedDebugArgs.concat(nonDebugArgs); | ||
} | ||
return args; | ||
}; |