forked from ruvnet/ruflo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·57 lines (47 loc) · 1.71 KB
/
cli.js
File metadata and controls
executable file
·57 lines (47 loc) · 1.71 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
52
53
54
55
56
57
#!/usr/bin/env node
// Node.js entry point for npx compatibility
// This file allows claude-flow to work with: npx claude-flow@latest <command>
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import { existsSync } from 'fs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Check if we have the compiled version
const compiledPath = join(__dirname, 'dist', 'cli', 'simple-cli.js');
const sourcePath = join(__dirname, 'src', 'cli', 'simple-cli.ts');
// Check which version exists
if (existsSync(compiledPath)) {
// Use the compiled JavaScript version
const cliProcess = spawn('node', [compiledPath, ...process.argv.slice(2)], {
stdio: 'inherit'
});
cliProcess.on('error', (error) => {
console.error('❌ Failed to run claude-flow:', error.message);
process.exit(1);
});
cliProcess.on('exit', (code) => {
process.exit(code || 0);
});
} else if (existsSync(sourcePath)) {
// Run TypeScript version with tsx
console.log('📦 Running TypeScript version...');
const tsxProcess = spawn('npx', ['tsx', sourcePath, ...process.argv.slice(2)], {
stdio: 'inherit',
shell: true
});
tsxProcess.on('error', (error) => {
console.error('❌ Failed to run claude-flow:', error.message);
console.log('\n💡 Try installing globally: npm install -g claude-flow');
process.exit(1);
});
tsxProcess.on('exit', (code) => {
process.exit(code || 0);
});
} else {
console.error('❌ Error: Could not find claude-flow implementation files');
console.error('Expected either:');
console.error(` - ${compiledPath}`);
console.error(` - ${sourcePath}`);
process.exit(1);
}