-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
51 lines (43 loc) · 1.48 KB
/
cli.js
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
const {spawn} = require('child_process');
const path = require('path');
const fs = require('fs');
const findBinary = require('.');
try {
// Get the actual path to the binary
const binaryPath = findBinary();
if (!binaryPath) {
console.error('Mew binary not found. Try running:');
console.error('npm remove @antharuu/mew');
console.error('npm install @antharuu/mew');
process.exit(1);
}
if (!fs.existsSync(binaryPath)) {
console.error(`Binary not found at: ${binaryPath}`);
console.error('Try reinstalling the package:');
console.error('npm remove @antharuu/mew');
console.error('npm install @antharuu/mew');
process.exit(1);
}
console.log('Using binary at:', binaryPath);
// Forward all arguments to the binary
const child = spawn(binaryPath, process.argv.slice(2), {
stdio: 'inherit'
});
child.on('error', (err) => {
console.error('Failed to start Mew:', err.message);
if (err.code === 'ENOENT') {
console.error('Binary not found or not executable.');
console.error('Try reinstalling the package:');
console.error('npm remove @antharuu/mew');
console.error('npm install @antharuu/mew');
}
process.exit(1);
});
child.on('exit', function (code) {
process.exit(code || 0);
});
} catch (error) {
console.error('Unexpected error:', error);
process.exit(1);
}