File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,6 @@ import pr from 'node:process';
33const cliArgs = pr . argv . slice ( 2 ) ;
44
55const parseArgs = ( ) => {
6- console . log ( cliArgs ) ;
7-
86 let arrToDisplay = [ ] ;
97
108 for ( let i = 0 ; i < cliArgs . length ; i += 2 ) {
Original file line number Diff line number Diff line change 1+ import { spawn } from 'node:child_process' ;
2+ import url from 'node:url' ;
3+ import path from 'node:path' ;
4+
5+ const __filename = url . fileURLToPath ( import . meta. url ) ;
6+ const __dirname = path . dirname ( __filename ) ;
7+
8+ const filePath = path . join ( __dirname , 'files' , 'script.js' ) ;
9+
110const spawnChildProcess = async ( args ) => {
2- // Write your code here
11+ const childProcess = spawn ( 'node' , [ filePath , ...args ] ) ;
12+
13+ process . stdin . pipe ( childProcess . stdin ) ;
14+ childProcess . stdout . pipe ( process . stdout ) ;
315} ;
416
517// Put your arguments in function call to test this functionality
6- spawnChildProcess ( /* [someArgument1, someArgument2, ... ] */ ) ;
18+ spawnChildProcess ( /* [someArgument1, someArgument2] */ ) ;
You can’t perform that action at this time.
0 commit comments