summaryrefslogtreecommitdiff
path: root/test/common/inspector-helper.js
diff options
context:
space:
mode:
authorMatteo Collina <hello@matteocollina.com>2018-07-04 19:55:12 +0200
committerMatteo Collina <hello@matteocollina.com>2018-07-07 00:04:52 +0200
commit19795d83833de7489afec583f8773ee9c0452f70 (patch)
tree0e495abfe821e92a158b757fcb0a24715fc7d863 /test/common/inspector-helper.js
parentdd023df135207086c86129aa1683ea4688f97f53 (diff)
downloadandroid-node-v8-19795d83833de7489afec583f8773ee9c0452f70.tar.gz
android-node-v8-19795d83833de7489afec583f8773ee9c0452f70.tar.bz2
android-node-v8-19795d83833de7489afec583f8773ee9c0452f70.zip
inspector: expose original console
Adds require('inspector').console, mapping it to the original global.console of V8. This enables applications to send messages to the inspector console programmatically. Fixes: https://github.com/nodejs/node/issues/21651 PR-URL: https://github.com/nodejs/node/pull/21659 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'test/common/inspector-helper.js')
-rw-r--r--test/common/inspector-helper.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js
index e590349f9c..1372604979 100644
--- a/test/common/inspector-helper.js
+++ b/test/common/inspector-helper.js
@@ -7,6 +7,7 @@ const fixtures = require('../common/fixtures');
const { spawn } = require('child_process');
const { parse: parseURL } = require('url');
const { getURLFromFilePath } = require('internal/url');
+const { EventEmitter } = require('events');
const _MAINSCRIPT = fixtures.path('loop.js');
const DEBUG = false;
@@ -311,10 +312,12 @@ class InspectorSession {
}
}
-class NodeInstance {
+class NodeInstance extends EventEmitter {
constructor(inspectorFlags = ['--inspect-brk=0'],
scriptContents = '',
scriptFile = _MAINSCRIPT) {
+ super();
+
this._scriptPath = scriptFile;
this._script = scriptFile ? null : scriptContents;
this._portCallback = null;
@@ -326,7 +329,10 @@ class NodeInstance {
this._unprocessedStderrLines = [];
this._process.stdout.on('data', makeBufferingDataCallback(
- (line) => console.log('[out]', line)));
+ (line) => {
+ this.emit('stdout', line);
+ console.log('[out]', line);
+ }));
this._process.stderr.on('data', makeBufferingDataCallback(
(message) => this.onStderrLine(message)));