-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🎨 add first class debugging support #2041
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
73c8729
:art: add first class debugging support
cdaringe 01ab6c9
:fire: drop --debug*
cdaringe f51b7d2
Revert ":fire: drop --debug*" per https://tinyurl.com/k546ycf
cdaringe 3e5e51c
fix(debug): disable inspect support per facebook/jest#1652
cdaringe fdd4474
docs(test): add debug instructions
cdaringe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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+)?$/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
are you sure? i'm not convinced we shouldn't support it! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They're going away in Node 8 iirc. |
||
/^--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; | ||
}; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it took me a while to figure out what was going on here--the
husky
git hook lint script kept changing the format out from under me!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙈
also, do we not already pass args in via
[require.resolve('../scripts/' + script)].concat(args)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont follow. are you suggesting just passing
script
togetArgs(...)
? that is,getArgs(script)
, and move that path resolution line into the other file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we already pass arguments through, just not to Node. I didn't realize the flags had to come first, sorry.
They're passed to the script.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right right right. if desired, we can annotate if you think its fitting somewhere, or rename the fn's to be more communicative