@@ -5,8 +5,6 @@ const { unzipSync } = require("zlib");
5
5
const packageJson = require ( "./package.json" ) ;
6
6
const fs = require ( "fs" ) ;
7
7
8
- function getPlatform ( ) { }
9
-
10
8
async function downloadCli ( version , platform ) {
11
9
const ext = platform . os === "win32" ? ".zip" : ".tar.gz" ;
12
10
const response = await fetch (
@@ -18,7 +16,7 @@ async function downloadCli(version, platform) {
18
16
try {
19
17
buffer = unzipSync ( tgz ) ;
20
18
} catch ( cause ) {
21
- throw new Error ( "Invalid gzip data" , { cause } ) ;
19
+ process . exit ( 1 ) ;
22
20
}
23
21
24
22
function str ( i , n ) {
@@ -29,20 +27,22 @@ async function downloadCli(version, platform) {
29
27
}
30
28
let offset = 0 ;
31
29
const dst = platform . exe ;
30
+ fs . mkdirSync ( "bin" , { recursive : true } ) ;
32
31
while ( offset < buffer . length ) {
33
- const name = str ( offset , 100 ) . replace ( "package/" , "" ) ;
34
32
const size = parseInt ( str ( offset + 124 , 12 ) , 8 ) ;
35
33
offset += 512 ;
36
34
if ( ! isNaN ( size ) ) {
37
35
write ( dst , buffer . subarray ( offset , offset + size ) ) ;
38
- if ( name === platform . exe ) {
39
- try {
40
- fs . chmodSync ( dst , 0o755 ) ;
41
- } catch ( error ) { }
42
- }
43
36
offset += ( size + 511 ) & ~ 511 ;
44
37
}
45
38
}
39
+ try {
40
+ fs . chmodSync ( dst , 0o755 ) ;
41
+ } catch ( error ) {
42
+ process . exit ( 1 ) ;
43
+ }
44
+
45
+ process . exit ( 0 ) ;
46
46
}
47
47
48
48
const fetch = "fetch" in globalThis ? webFetch : nodeFetch ;
@@ -145,13 +145,13 @@ const platforms = [
145
145
os : "win32" ,
146
146
arch : "x64" ,
147
147
bin : "new-dockerfile-windows-x86_64" ,
148
- exe : "bin/new-dockerfile.exe " ,
148
+ exe : "bin/new-dockerfile" ,
149
149
} ,
150
150
{
151
151
os : "win32" ,
152
152
arch : "arm64" ,
153
153
bin : "new-dockerfile-windows-arm64" ,
154
- exe : "bin/new-dockerfile.exe " ,
154
+ exe : "bin/new-dockerfile" ,
155
155
} ,
156
156
] ;
157
157
@@ -205,4 +205,10 @@ if (supportedPlatforms.length === 0) {
205
205
}
206
206
207
207
// Read version from package.json
208
+
209
+ function wait ( ) {
210
+ setTimeout ( wait , 1000 ) ;
211
+ }
212
+
208
213
downloadCli ( packageJson . config . bin_version , supportedPlatforms [ 0 ] ) ;
214
+ wait ( ) ;
0 commit comments