()
| 75 | } |
| 76 | |
| 77 | function guessEditor(): Array<string> { |
| 78 | // Explicit config always wins |
| 79 | if (process.env.REACT_EDITOR) { |
| 80 | return parse(process.env.REACT_EDITOR); |
| 81 | } |
| 82 | |
| 83 | // Using `ps x` on OSX we can find out which editor is currently running. |
| 84 | // Potentially we could use similar technique for Windows and Linux |
| 85 | if (process.platform === 'darwin') { |
| 86 | try { |
| 87 | const output = execSync('ps x').toString(); |
| 88 | const processNames = Object.keys(COMMON_EDITORS); |
| 89 | for (let i = 0; i < processNames.length; i++) { |
| 90 | const processName = processNames[i]; |
| 91 | if (output.indexOf(processName) !== -1) { |
| 92 | return [COMMON_EDITORS[processName]]; |
| 93 | } |
| 94 | } |
| 95 | } catch (error) { |
| 96 | // Ignore... |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | // Last resort, use old-school env vars |
| 101 | if (process.env.VISUAL) { |
| 102 | return [process.env.VISUAL]; |
| 103 | } else if (process.env.EDITOR) { |
| 104 | return [process.env.EDITOR]; |
| 105 | } |
| 106 | |
| 107 | return []; |
| 108 | } |
| 109 | |
| 110 | let childProcess = null; |
| 111 |
no test coverage detected