forked from the-markup/blacklight-collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.mjs
executable file
·33 lines (24 loc) · 795 Bytes
/
index.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env node
// import { exec } from 'child_process';
import { spawn } from 'child_process';
const url = process.argv.slice(2);
const file = './example.ts';
console.log(`url: ${url}`);
const child = spawn('npx', ['ts-node', file], { stdio: 'inherit' });
child.on('error', (error) => {
console.error(`Error: ${error.message}`);
});
child.on('close', (code) => {
console.log(`Child process exited with code ${code}`);
});
// exec(`npx ts-node example.ts ${url}`, (error, stdout, stderr) => {
// if (error) {
// console.error(`Error executing ${file}: ${error.message}`);
// return;
// }
// if (stderr) {
// console.error(`Error output from ${file}: ${stderr}`);
// return;
// }
// console.log("script run, output produced")
// });