Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(links): open files in configured editor
If filenames are absolute the generated links can be opened in an editor if the `editorScheme` property is set. If `react-transform-catch-errors` passes in a `filename` this is used for the top function if the stack trace filename isn't absolute Closes: #10
- Loading branch information
Showing
10 changed files
with
494 additions
and
13 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,7 @@ | |||
{ | { | ||
"stage": 0, | "stage": 0, | ||
"loose": "all" | "loose": "all", | ||
"plugins": [ | |||
"rewire" | |||
] | |||
} | } |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,63 @@ | |||
export const filenameWithoutLoaders = (filename) => { | |||
var index = filename.lastIndexOf('!') | |||
|
|||
return index < 0 ? filename : filename.substr(index + 1) | |||
} | |||
|
|||
export const filenameHasLoaders = (filename) => { | |||
const actualFilename = filenameWithoutLoaders(filename) | |||
|
|||
return actualFilename !== filename | |||
} | |||
|
|||
export const filenameHasSchema = (filename) => { | |||
return /^[\w]+\:/.test(filename) | |||
} | |||
|
|||
export const isFilenameAbsolute = (filename) => { | |||
const actualFilename = filenameWithoutLoaders(filename) | |||
|
|||
if (actualFilename.indexOf('/') === 0) { | |||
return true | |||
} | |||
|
|||
return false | |||
} | |||
|
|||
export const makeUrl = (filename, scheme, line, column) => { | |||
let actualFilename = filenameWithoutLoaders(filename) | |||
|
|||
if (filenameHasSchema(filename)) { | |||
return actualFilename | |||
} | |||
|
|||
let url = `file://${actualFilename}` | |||
|
|||
if (scheme) { | |||
url = `${scheme}://open?url=${url}` | |||
|
|||
if (line && actualFilename === filename) { | |||
url = `${url}&line=${line}` | |||
|
|||
if (column) { | |||
url = `${url}&column=${column}` | |||
} | |||
} | |||
} | |||
|
|||
return url | |||
} | |||
|
|||
export const makeLinkText = (filename, line, column) => { | |||
let text = filenameWithoutLoaders(filename) | |||
|
|||
if (line && text === filename) { | |||
text = `${text}:${line}` | |||
|
|||
if (column) { | |||
text = `${text}:${column}` | |||
} | |||
} | |||
|
|||
return text | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,5 +1,5 @@ | |||
import framesStub from './framesStub.json' | export default (framesStub) => { | ||
|
return { | ||
export default { | parse: () => framesStub | ||
parse: () => framesStub | } | ||
} | } |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1 +1,14 @@ | |||
[{"functionName":"App.render","fileName":"webpack:///./components/App.js?","lineNumber":45,"columnNumber":12},{"functionName":"App.render","fileName":"webpack:///./~/react-hot-loader/~/react-hot-api/modules/makeAssimilatePrototype.js?","lineNumber":17,"columnNumber":41},{"functionName":"ReactCompositeComponentMixin._renderValidatedComponentWithoutOwnerOrContext","fileName":"webpack:///./~/react/lib/ReactCompositeComponent.js?","lineNumber":789,"columnNumber":34},{"functionName":"ReactCompositeComponentMixin._renderValidatedComponent","fileName":"webpack:///./~/react/lib/ReactCompositeComponent.js?","lineNumber":816,"columnNumber":14},{"functionName":"ReactPerf.measure.wrapper","fileName":"webpack:///./~/react/lib/ReactPerf.js?","lineNumber":70,"columnNumber":21},{"functionName":"ReactCompositeComponentMixin.mountComponent","fileName":"webpack:///./~/react/lib/ReactCompositeComponent.js?","lineNumber":237,"columnNumber":30},{"functionName":"ReactPerf.measure.wrapper","fileName":"webpack:///./~/react/lib/ReactPerf.js?","lineNumber":70,"columnNumber":21},{"functionName":"Object.ReactReconciler.mountComponent","fileName":"webpack:///./~/react/lib/ReactReconciler.js?","lineNumber":38,"columnNumber":35},{"functionName":"mountComponentIntoNode","fileName":"webpack:///./~/react/lib/ReactMount.js?","lineNumber":248,"columnNumber":32},{"functionName":"ReactReconcileTransaction.Mixin.perform","fileName":"webpack:///./~/react/lib/Transaction.js?","lineNumber":134,"columnNumber":20}] | [ | ||
{ | |||
"functionName": "App.render", | |||
"fileName": "webpack:\/\/\/.\/components\/App.js?", | |||
"lineNumber": 45, | |||
"columnNumber": 12 | |||
}, | |||
{ | |||
"functionName": "App.render", | |||
"fileName": "webpack:\/\/\/.\/~\/react-hot-loader\/~\/react-hot-api\/modules\/makeAssimilatePrototype.js?", | |||
"lineNumber": 17, | |||
"columnNumber": 41 | |||
} | |||
] |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,14 @@ | |||
[ | |||
{ | |||
"functionName": "App.render", | |||
"fileName": "\/components\/App.js", | |||
"lineNumber": 45, | |||
"columnNumber": 12 | |||
}, | |||
{ | |||
"functionName": "App.render", | |||
"fileName": "\/some-path\/modules\/makeAssimilatePrototype.js", | |||
"lineNumber": 17, | |||
"columnNumber": 41 | |||
} | |||
] |
Oops, something went wrong.