Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 3 additions & 27 deletions packages/debugger-shell/src/node/index.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from './private/LaunchUtils';

const {spawn} = require('cross-spawn');
const debug = require('debug')('Metro:Debugger:DebuggerShell');
const path = require('path');

// The 'prebuilt' flavor will use the prebuilt shell binary (and the JavaScript embedded in it).
Expand Down Expand Up @@ -56,59 +55,36 @@ async function unstable_spawnDebuggerShellWithArgs(
...env
} = process.env;
const child = spawn(binaryPath, [...baseArgs, ...args], {
stdio: ['ignore', 'pipe', 'pipe'],
stdio: 'inherit',
windowsHide: true,
detached: mode === 'detached',
env,
});
if (mode === 'detached') {
child.on('spawn', () => {
debug('Debugger spawned in detached mode');
resolve();
});
child.on('close', (code: number, signal) => {
debug('Debugger closed with code %s and signal %s', code, signal);
child.on('close', (code: number) => {
if (code !== 0) {
console.error(
'Debugger closed with code %s and signal %s',
code,
signal,
);
reject(
new Error(
`Failed to open debugger shell: exited with code ${code}`,
),
);
}
});
child.on('error', error => {
debug('Debugger shell encountered error: %s', error);
reject(error);
});
child.stdout.on('data', data =>
console.debug('[DebuggerShell stdout] ' + String(data)),
);
child.stderr.on('data', data =>
console.debug('[DebuggerShell stderr] ' + String(data)),
);
child.unref();
} else if (mode === 'syncThenExit') {
child.on('close', function (code, signal) {
debug('Debugger closed with code %s and signal %s', code, signal);
if (code === null) {
console.error(
'Debugger closed with code %s and signal %s',
code,
signal,
);
console.error('Debugger shell exited with signal', signal);
process.exit(1);
}
process.exit(code);
});

const handleTerminationSignal = function (signal: string) {
process.on(signal, function signalHandler() {
debug('The Signal %s received. killing debugger', signal);
if (!child.killed) {
child.kill(signal);
}
Expand Down
Loading