-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.js
More file actions
executable file
·23 lines (21 loc) · 853 Bytes
/
Copy pathrun.js
File metadata and controls
executable file
·23 lines (21 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env node
// Run TypeScript directly without build step
const { spawnSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const nodeDir = path.dirname(process.execPath);
const env = { ...process.env, PATH: `${nodeDir}${path.delimiter}${process.env.PATH}` };
const compiled = path.join(__dirname, 'dist', 'index.js');
let result;
if (fs.existsSync(compiled)) {
result = spawnSync(process.execPath, [compiled, ...process.argv.slice(2)], { stdio: 'inherit', env });
} else {
const tsx = path.join(__dirname, 'node_modules', '.bin', 'tsx');
const entry = path.join(__dirname, 'src', 'index.ts');
result = spawnSync(tsx, [entry, ...process.argv.slice(2)], { stdio: 'inherit', env });
}
if (result.error) {
console.error(result.error.message);
process.exit(1);
}
process.exit(result.status ?? 1);