Skip to content

Commit 364fab4

Browse files
committed
use input/output events from syncline
1 parent a896ebf commit 364fab4

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/node/node-wsh.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ export class WindowsScriptingHost extends EventEmitter {
1212
const command = options.command || COMMAND;
1313
const args = options.args || ARGS;
1414
const scriptFile = options.scriptFile || SCRIPT_FILE;
15-
const trace = options.trace || 0;
16-
return new WindowsScriptingHost( await Syncline.spawn( command, [ ...args, scriptFile], { trace}));
15+
return new WindowsScriptingHost( await Syncline.spawn( command, [ ...args, scriptFile], options.syncline), options);
1716
}
1817

1918
#syncline;
@@ -22,11 +21,15 @@ export class WindowsScriptingHost extends EventEmitter {
2221
#ref2proxy = new Map(); // Map< string, WeakRef< Proxy | <custom-mapped>>>
2322
#proxy2ref = new WeakMap(); // Map< Proxy | <custom-mapped>, string>
2423

25-
constructor( syncline) {
24+
constructor( syncline, options) {
2625
super();
2726
this.#syncline = syncline;
2827
this.#syncline.on( 'stderr', line => console.log( 'wsh-stderr:', line));
2928
this.#syncline.on( 'stdout', line => console.log( 'wsh-stdout:', line));
29+
if( options.printSynclineIO) {
30+
this.#syncline.on( 'input', line => console.log( 'syncline-input:', line));
31+
this.#syncline.on( 'output', line => console.log( 'syncline-output', line));
32+
}
3033
}
3134

3235
get remoteObjects() {

test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import TEST from 'node:test';
33
import { WindowsScriptingHost} from '@arcticnotes/node-wsh';
44

55
TEST( 'smoke-test', async() => {
6-
const wsh = await WindowsScriptingHost.connect();
6+
const wsh = await WindowsScriptingHost.connect( { printSynclineIO: true});
77
try {
88
wsh.on( 'ref', ( ref, obj) => console.log( 'ref', ref, obj));
99
wsh.on( 'unref', ref => console.log( 'unref', ref));
@@ -29,7 +29,7 @@ TEST( 'smoke-test', async() => {
2929
});
3030

3131
TEST( 'vbarray', async() => {
32-
const wsh = await WindowsScriptingHost.connect();
32+
const wsh = await WindowsScriptingHost.connect( { printSynclineIO: true});
3333
try {
3434
const CreateVBArray = wsh.global( 'CreateVBArray');
3535
ASSERT.equal( typeof CreateVBArray( [ 1, 3, 5]), 'function');

0 commit comments

Comments
 (0)