-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (28 loc) · 1.2 KB
/
index.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
const path = require('path');
const fs = require('fs');
const os = require('os');
function getBinaryName() {
return os.platform() === 'win32' ? 'mew.exe' : 'mew';
}
function findBinary() {
const binaryName = getBinaryName();
// Chemins possibles pour le binaire
const possiblePaths = [
path.join(__dirname, binaryName), // Dans le dossier actuel
path.join(process.cwd(), 'target', 'release', binaryName), // Dans target/release du dossier courant
path.join(process.cwd(), '..', 'target', 'release', binaryName), // Dans target/release du dossier parent
path.join(__dirname, 'target', 'release', binaryName), // Dans target/release relatif au module
path.join(__dirname, '..', 'target', 'release', binaryName) // Dans target/release du parent du module
];
console.log('Looking for binary in:');
for (const binPath of possiblePaths) {
console.log('- ', binPath);
if (fs.existsSync(binPath)) {
console.log('Found binary at:', binPath);
return binPath;
}
}
console.log('No binary found in any of the expected locations');
return null;
}
module.exports = findBinary;