Merge pull request #9739 from electron/inspect_flag_fork_patch
app: add support for inspect/inspect-brk in forked node process
This commit is contained in:
commit
014aaccfc6
4 changed files with 46 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "atom/app/uv_task_runner.h"
|
||||
#include "atom/browser/javascript_environment.h"
|
||||
#include "atom/browser/node_debugger.h"
|
||||
#include "atom/common/api/atom_bindings.h"
|
||||
#include "atom/common/crash_reporter/crash_reporter.h"
|
||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||
|
@ -50,6 +51,10 @@ int NodeMain(int argc, char *argv[]) {
|
|||
&isolate_data, gin_env.context(), argc, argv,
|
||||
exec_argc, exec_argv);
|
||||
|
||||
// Enable support for v8 inspector.
|
||||
NodeDebugger node_debugger(env);
|
||||
node_debugger.Start();
|
||||
|
||||
mate::Dictionary process(gin_env.isolate(), env->process_object());
|
||||
#if defined(OS_WIN)
|
||||
process.SetMethod("log", &AtomBindings::Log);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "libplatform/libplatform.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
|
||||
namespace atom {
|
||||
|
||||
NodeDebugger::NodeDebugger(node::Environment* env) : env_(env) {
|
||||
|
|
|
@ -7,7 +7,15 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#include "atom/common/node_includes.h"
|
||||
#include "base/macros.h"
|
||||
|
||||
namespace node {
|
||||
class Environment;
|
||||
}
|
||||
|
||||
namespace v8 {
|
||||
class Platform;
|
||||
}
|
||||
|
||||
namespace atom {
|
||||
|
||||
|
|
|
@ -104,8 +104,16 @@ describe('node feature', function () {
|
|||
})
|
||||
|
||||
describe('child_process.spawn', function () {
|
||||
let child
|
||||
|
||||
afterEach(function () {
|
||||
if (child != null) {
|
||||
child.kill()
|
||||
}
|
||||
})
|
||||
|
||||
it('supports spawning Electron as a node process via the ELECTRON_RUN_AS_NODE env var', function (done) {
|
||||
const child = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], {
|
||||
child = ChildProcess.spawn(process.execPath, [path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], {
|
||||
env: {
|
||||
ELECTRON_RUN_AS_NODE: true
|
||||
}
|
||||
|
@ -124,6 +132,27 @@ describe('node feature', function () {
|
|||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('supports starting the v8 inspector with --inspect/--inspect-brk', function (done) {
|
||||
child = ChildProcess.spawn(process.execPath, ['--inspect-brk', path.join(__dirname, 'fixtures', 'module', 'run-as-node.js')], {
|
||||
env: {
|
||||
ELECTRON_RUN_AS_NODE: true
|
||||
}
|
||||
})
|
||||
|
||||
let output = ''
|
||||
child.stderr.on('data', function (data) {
|
||||
output += data
|
||||
|
||||
if (output.trim().startsWith('Debugger listening on port')) {
|
||||
done()
|
||||
}
|
||||
})
|
||||
|
||||
child.stdout.on('data', function (data) {
|
||||
done(new Error(`Unexpected output: ${data.toString()}`))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue