@ceschiatti/redistail 0.0.1
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/dist/cli/redistail-launcher.js +65 -0
- package/dist/cli/redistail.exe +0 -0
- package/dist/cli/redistail.js +110 -0
- package/package.json +37 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cross-platform launcher for redistail CLI
|
|
5
|
+
* Detects platform and runs the appropriate binary
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { spawn } from 'node:child_process';
|
|
9
|
+
import { fileURLToPath } from 'node:url';
|
|
10
|
+
import { dirname, join } from 'node:path';
|
|
11
|
+
import { existsSync } from 'node:fs';
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = dirname(__filename);
|
|
15
|
+
|
|
16
|
+
function launchRedistail() {
|
|
17
|
+
const args = process.argv.slice(2);
|
|
18
|
+
|
|
19
|
+
// Try to use the compiled executable first (better performance)
|
|
20
|
+
const exePath = join(__dirname, 'redistail.exe');
|
|
21
|
+
const jsPath = join(__dirname, 'redistail.js');
|
|
22
|
+
|
|
23
|
+
let command;
|
|
24
|
+
let commandArgs;
|
|
25
|
+
|
|
26
|
+
if (process.platform === 'win32' && existsSync(exePath)) {
|
|
27
|
+
// Use the compiled executable on Windows
|
|
28
|
+
command = exePath;
|
|
29
|
+
commandArgs = args;
|
|
30
|
+
} else if (existsSync(jsPath)) {
|
|
31
|
+
// Fall back to Node.js execution
|
|
32
|
+
command = 'node';
|
|
33
|
+
commandArgs = [jsPath, ...args];
|
|
34
|
+
} else {
|
|
35
|
+
console.error('Error: redistail binary not found');
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Spawn the process and pipe stdio
|
|
40
|
+
const child = spawn(command, commandArgs, {
|
|
41
|
+
stdio: 'inherit',
|
|
42
|
+
windowsHide: false,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Handle process exit
|
|
46
|
+
child.on('close', (code) => {
|
|
47
|
+
process.exit(code || 0);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
child.on('error', (error) => {
|
|
51
|
+
console.error('Error launching redistail:', error.message);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Handle process signals
|
|
56
|
+
process.on('SIGINT', () => {
|
|
57
|
+
child.kill('SIGINT');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
process.on('SIGTERM', () => {
|
|
61
|
+
child.kill('SIGTERM');
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
launchRedistail();
|
|
Binary file
|