-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnpx-runner.js
More file actions
executable file
·51 lines (43 loc) · 1.32 KB
/
npx-runner.js
File metadata and controls
executable file
·51 lines (43 loc) · 1.32 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env node
/**
* NPX Runner for Conductor CLI
* Enables: npx conductor-cli <command>
*/
const { spawn } = require('child_process');
const path = require('path');
const fs = require('fs');
// Detect if running via npx
const isNpx = !require.main.filename.includes('node_modules/.bin');
// Get the actual CLI path
const cliPath = path.join(__dirname, 'dist', 'enhanced-cli.js');
// Check if built files exist
if (!fs.existsSync(cliPath)) {
console.log('⏳ First run detected - Building Conductor CLI...');
try {
// Build the project
require('child_process').execSync('npm run build', {
cwd: __dirname,
stdio: 'inherit'
});
} catch (error) {
console.error('❌ Build failed. Trying fallback mode...');
// Fallback to TypeScript runner
const tsxPath = path.join(__dirname, 'src', 'enhanced-cli.ts');
require('child_process').spawn('npx', ['tsx', tsxPath, ...process.argv.slice(2)], {
stdio: 'inherit',
shell: true
});
return;
}
}
// Run the CLI with passed arguments
const child = spawn('node', [cliPath, ...process.argv.slice(2)], {
stdio: 'inherit',
env: {
...process.env,
CONDUCTOR_NPX_MODE: 'true'
}
});
child.on('exit', (code) => {
process.exit(code);
});