Skip to content

Commit abdd5da

Browse files
committed
feat(wt): implemented logic in cp function
1 parent 568a26e commit abdd5da

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/cli/args.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import pr from 'node:process';
33
const cliArgs = pr.argv.slice(2);
44

55
const parseArgs = () => {
6-
console.log(cliArgs);
7-
86
let arrToDisplay = [];
97

108
for (let i = 0; i < cliArgs.length; i += 2) {

src/cp/cp.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
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+
110
const 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] */);

0 commit comments

Comments
 (0)