From e08a7f35876cf102a6453273a71d8664debfb55c Mon Sep 17 00:00:00 2001 From: Janic Duplessis Date: Mon, 11 Jan 2016 13:27:00 -0800 Subject: [PATCH] Fix launching text editor from a redbox stacktrace on windows Summary: Launch the editor with cmd on windows. Closes https://github.com/facebook/react-native/pull/5238 Reviewed By: svcscm Differential Revision: D2819943 Pulled By: pcottle fb-gh-sync-id: a38f88bb9be72871cc3a37367973371176799d9e --- local-cli/server/util/launchEditor.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/local-cli/server/util/launchEditor.js b/local-cli/server/util/launchEditor.js index a456eda59..ee8445294 100644 --- a/local-cli/server/util/launchEditor.js +++ b/local-cli/server/util/launchEditor.js @@ -125,7 +125,13 @@ function launchEditor(fileName, lineNumber) { _childProcess.kill('SIGKILL'); } - _childProcess = child_process.spawn(editor, args, {stdio: 'inherit'}); + if (process.platform === 'win32') { + // On Windows, launch the editor in a shell because spawn can only + // launch .exe files. + _childProcess = child_process.spawn('cmd.exe', ['/C', editor].concat(args), {stdio: 'inherit'}); + } else { + _childProcess = child_process.spawn(editor, args, {stdio: 'inherit'}); + } _childProcess.on('exit', function(errorCode) { _childProcess = null;