@treeship/cli-darwin-arm64 0.1.0
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/binary.js +2 -0
- package/package.json +11 -0
- package/postinstall.js +41 -0
package/binary.js
ADDED
package/package.json
ADDED
package/postinstall.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const VERSION = require('./package.json').version;
|
|
6
|
+
const BINARY_NAME = 'treeship-darwin-aarch64';
|
|
7
|
+
const URL = 'https://github.com/zerkerlabs/treeship/releases/download/v' + VERSION + '/' + BINARY_NAME;
|
|
8
|
+
const DEST = path.join(__dirname, 'bin', 'treeship');
|
|
9
|
+
|
|
10
|
+
if (fs.existsSync(DEST)) process.exit(0);
|
|
11
|
+
|
|
12
|
+
fs.mkdirSync(path.join(__dirname, 'bin'), { recursive: true });
|
|
13
|
+
|
|
14
|
+
console.log('treeship: downloading ' + BINARY_NAME + '...');
|
|
15
|
+
|
|
16
|
+
function download(url) {
|
|
17
|
+
https.get(url, (res) => {
|
|
18
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
19
|
+
download(res.headers.location);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (res.statusCode !== 200) {
|
|
23
|
+
console.error('treeship: download failed (' + res.statusCode + ')');
|
|
24
|
+
console.error('Install manually: cargo install treeship-cli');
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
const file = fs.createWriteStream(DEST);
|
|
28
|
+
res.pipe(file);
|
|
29
|
+
file.on('finish', () => {
|
|
30
|
+
file.close();
|
|
31
|
+
fs.chmodSync(DEST, 0o755);
|
|
32
|
+
console.log('treeship: installed');
|
|
33
|
+
});
|
|
34
|
+
}).on('error', () => {
|
|
35
|
+
console.error('treeship: download failed');
|
|
36
|
+
console.error('Install manually: cargo install treeship-cli');
|
|
37
|
+
process.exit(0);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
download(URL);
|