-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-contextr.js
More file actions
executable file
·67 lines (55 loc) · 1.61 KB
/
run-contextr.js
File metadata and controls
executable file
·67 lines (55 loc) · 1.61 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
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env node
// This script runs contextr without building it
const { spawn } = require('child_process');
const path = require('path');
const fs = require('fs');
// Create a temporary directory for the build
const tempDir = path.join(__dirname, 'temp-build');
if (!fs.existsSync(tempDir)) {
fs.mkdirSync(tempDir, { recursive: true });
}
// Get command line arguments
const args = process.argv.slice(2);
// If no arguments provided, show help
if (args.length === 0) {
console.log(`
Contextr Runner
--------------
This script helps you run contextr without building it.
Usage:
node run-contextr.js <command> [options]
Commands:
build Build context from your project files
search Search for content within files
studio Launch the ContextR Studio UI
example Run the example-usage.ts file
Examples:
node run-contextr.js build --dir src --output context.txt
node run-contextr.js search "TODO" --dir src
node run-contextr.js studio
node run-contextr.js example
`);
process.exit(0);
}
// Handle the example command separately
if (args[0] === 'example') {
runCommand('npx', ['tsx', 'example-usage.ts']);
process.exit(0);
}
// For other commands, pass them to the CLI
runCommand('npx', ['tsx', 'src/cli/index.ts', ...args]);
function runCommand(cmd, args) {
const proc = spawn(cmd, args, {
stdio: 'inherit',
shell: process.platform === 'win32'
});
proc.on('error', (err) => {
console.error('Failed to run command:', err);
process.exit(1);
});
proc.on('close', (code) => {
if (code !== 0) {
console.error(`Command exited with code ${code}`);
}
});
}