launchEditor() — react Function Reference
Architecture documentation for the launchEditor() function in editor.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD e8507b55_91a3_8bd9_66bd_762108bb46c6["launchEditor()"] 39f6c195_7b6b_6f87_7437_5d782daf3565["editor.js"] e8507b55_91a3_8bd9_66bd_762108bb46c6 -->|defined in| 39f6c195_7b6b_6f87_7437_5d782daf3565 8f292aac_c808_e1ff_4d0a_3a933ef58bee["getValidFilePath()"] e8507b55_91a3_8bd9_66bd_762108bb46c6 -->|calls| 8f292aac_c808_e1ff_4d0a_3a933ef58bee 69e6ca1c_8316_7a87_603d_cb11c67925e2["guessEditor()"] e8507b55_91a3_8bd9_66bd_762108bb46c6 -->|calls| 69e6ca1c_8316_7a87_603d_cb11c67925e2 66036873_ee4a_5381_bf69_104a3d91195b["getArgumentsForLineNumber()"] e8507b55_91a3_8bd9_66bd_762108bb46c6 -->|calls| 66036873_ee4a_5381_bf69_104a3d91195b 9c2e9d58_f552_a8a9_5e8a_e40711bf9e40["isTerminalEditor()"] e8507b55_91a3_8bd9_66bd_762108bb46c6 -->|calls| 9c2e9d58_f552_a8a9_5e8a_e40711bf9e40 style e8507b55_91a3_8bd9_66bd_762108bb46c6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-core/src/editor.js lines 143–194
export function launchEditor(
maybeRelativePath: string,
lineNumber: number,
absoluteProjectRoots: Array<string>,
) {
const filePath = getValidFilePath(maybeRelativePath, absoluteProjectRoots);
if (filePath === null) {
return;
}
// Sanitize lineNumber to prevent malicious use on win32
// via: https://github.com/nodejs/node/blob/c3bb4b1aa5e907d489619fb43d233c3336bfc03d/lib/child_process.js#L333
if (lineNumber && isNaN(lineNumber)) {
return;
}
const [editor, ...destructuredArgs] = guessEditor();
if (!editor) {
return;
}
let args = destructuredArgs;
if (lineNumber) {
args = args.concat(getArgumentsForLineNumber(editor, filePath, lineNumber));
} else {
args.push(filePath);
}
if (childProcess && isTerminalEditor(editor)) {
// There's an existing editor process already and it's attached
// to the terminal, so go kill it. Otherwise two separate editor
// instances attach to the stdin/stdout which gets confusing.
// $FlowFixMe[incompatible-use] found when upgrading Flow
childProcess.kill('SIGKILL');
}
if (process.platform === 'win32') {
// On Windows, launch the editor in a shell because spawn can only
// launch .exe files.
childProcess = spawn('cmd.exe', ['/C', editor].concat(args), {
stdio: 'inherit',
});
} else {
childProcess = spawn(editor, args, {stdio: 'inherit'});
}
childProcess.on('error', function () {});
// $FlowFixMe[incompatible-use] found when upgrading Flow
childProcess.on('exit', function () {
childProcess = null;
});
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does launchEditor() do?
launchEditor() is a function in the react codebase, defined in packages/react-devtools-core/src/editor.js.
Where is launchEditor() defined?
launchEditor() is defined in packages/react-devtools-core/src/editor.js at line 143.
What does launchEditor() call?
launchEditor() calls 4 function(s): getArgumentsForLineNumber, getValidFilePath, guessEditor, isTerminalEditor.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free