@sheepbun/yips 0.1.46 → 0.1.47
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/package.json +1 -1
- package/postinstall.js +29 -27
package/package.json
CHANGED
package/postinstall.js
CHANGED
|
@@ -5,8 +5,8 @@ const os = require('os');
|
|
|
5
5
|
|
|
6
6
|
const isWin = os.platform() === 'win32';
|
|
7
7
|
const ext = isWin ? '.exe' : '';
|
|
8
|
-
const binaryName = isWin ? 'yips-windows.exe' : 'yips-linux';
|
|
9
|
-
const
|
|
8
|
+
const binaryName = isWin ? 'yips-core-windows.exe' : 'yips-core-linux';
|
|
9
|
+
const initialUrl = `https://github.com/sheepbun/yips/releases/latest/download/${binaryName}`;
|
|
10
10
|
const binDir = path.join(__dirname, 'bin');
|
|
11
11
|
|
|
12
12
|
if (!fs.existsSync(binDir)) {
|
|
@@ -15,35 +15,37 @@ if (!fs.existsSync(binDir)) {
|
|
|
15
15
|
|
|
16
16
|
const dest = path.join(binDir, `yips${ext}`);
|
|
17
17
|
|
|
18
|
-
console.log(`Downloading Yips binary from ${
|
|
18
|
+
console.log(`Downloading Yips binary from ${initialUrl}...`);
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
20
|
+
function download(url) {
|
|
21
|
+
https.get(url, (res) => {
|
|
22
|
+
if (res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 307 || res.statusCode === 308) {
|
|
23
|
+
// Follow redirect
|
|
24
|
+
if (res.headers.location) {
|
|
25
|
+
download(res.headers.location);
|
|
26
|
+
} else {
|
|
27
|
+
console.error(`Redirect without location header (status ${res.statusCode})`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
} else if (res.statusCode === 200) {
|
|
31
|
+
const file = fs.createWriteStream(dest);
|
|
32
|
+
res.pipe(file);
|
|
33
|
+
file.on('finish', () => {
|
|
34
|
+
file.close();
|
|
35
|
+
if (!isWin) {
|
|
36
|
+
fs.chmodSync(dest, 0o755);
|
|
37
|
+
}
|
|
38
|
+
console.log('Downloaded Yips binary successfully.');
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
console.error(`Failed to download: HTTP ${res.statusCode}`);
|
|
42
|
+
process.exit(1);
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
});
|
|
44
|
+
}).on('error', handleError);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
download(initialUrl);
|
|
48
|
+
|
|
47
49
|
function handleError(err) {
|
|
48
50
|
console.error('Error downloading Yips:', err.message);
|
|
49
51
|
process.exit(1);
|