cc-pipeline 0.6.1 → 0.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cc-pipeline.js +24 -11
- package/package.json +1 -1
package/bin/cc-pipeline.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
|
|
6
|
-
// Use createRequire to resolve tsx relative to this package (handles hoisted deps)
|
|
2
|
+
// tsx v4+ requires --import, not the loader hooks API.
|
|
3
|
+
// Spawn node with --import tsx/esm, resolving tsx relative to this package
|
|
4
|
+
// so it works regardless of npm hoisting.
|
|
5
|
+
import { spawn } from 'node:child_process';
|
|
7
6
|
import { createRequire } from 'node:module';
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
8
|
+
import { dirname, join } from 'node:path';
|
|
9
|
+
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
11
|
const require = createRequire(import.meta.url);
|
|
9
|
-
const tsxApiPath = require.resolve('tsx/dist/esm/api/index.mjs');
|
|
10
|
-
const { register } = await import(tsxApiPath);
|
|
11
|
-
register();
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
const tsxEsm = pathToFileURL(require.resolve('tsx/esm')).href;
|
|
14
|
+
const cli = join(__dirname, '../src/cli.ts');
|
|
15
|
+
|
|
16
|
+
const child = spawn(
|
|
17
|
+
process.execPath,
|
|
18
|
+
['--import', tsxEsm, cli, ...process.argv.slice(2)],
|
|
19
|
+
{ stdio: 'inherit' }
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// SIGINT is broadcast to the whole process group on Ctrl-C, but SIGTERM is not.
|
|
23
|
+
process.on('SIGTERM', () => child.kill('SIGTERM'));
|
|
24
|
+
|
|
25
|
+
child.on('exit', (code, signal) => {
|
|
26
|
+
if (signal) process.kill(process.pid, signal);
|
|
27
|
+
else process.exit(code ?? 0);
|
|
28
|
+
});
|
package/package.json
CHANGED