@@ -2,6 +2,7 @@ import zip from "adm-zip"
2
2
import * as assert from "assert"
3
3
import * as fs from "fs-extra"
4
4
import * as http from "http"
5
+ import * as os from "os"
5
6
import * as path from "path"
6
7
import * as tar from "tar-fs"
7
8
import * as zlib from "zlib"
@@ -65,7 +66,20 @@ describe("update", () => {
65
66
}
66
67
67
68
before ( async ( ) => {
68
- const archiveName = "code-server-9999999.99999.9999-linux-x86_64"
69
+ await new Promise ( ( resolve , reject ) => {
70
+ server . on ( "error" , reject )
71
+ server . on ( "listening" , resolve )
72
+ server . listen ( {
73
+ port : 0 ,
74
+ host : "localhost" ,
75
+ } )
76
+ } )
77
+
78
+ const p = provider ( )
79
+ const archiveName = ( await p . getReleaseName ( { version : "9999999.99999.9999" , checked : 0 } ) ) . replace (
80
+ / .t a r .g z $ | .z i p $ / ,
81
+ "" ,
82
+ )
69
83
await fs . remove ( path . join ( tmpdir , "tests/updates" ) )
70
84
await fs . mkdirp ( path . join ( archivePath , archiveName ) )
71
85
@@ -74,8 +88,16 @@ describe("update", () => {
74
88
fs . writeFile ( path . join ( archivePath , archiveName , "node" ) , `NODE BINARY` ) ,
75
89
] )
76
90
77
- await Promise . all ( [
78
- new Promise ( ( resolve , reject ) => {
91
+ if ( os . platform ( ) === "darwin" ) {
92
+ await new Promise ( ( resolve , reject ) => {
93
+ const zipFile = new zip ( )
94
+ zipFile . addLocalFolder ( archivePath )
95
+ zipFile . writeZip ( archivePath + ".zip" , ( error ) => {
96
+ return error ? reject ( error ) : resolve ( error )
97
+ } )
98
+ } )
99
+ } else {
100
+ await new Promise ( ( resolve , reject ) => {
79
101
const write = fs . createWriteStream ( archivePath + ".tar.gz" )
80
102
const compress = zlib . createGzip ( )
81
103
compress . pipe ( write )
@@ -86,24 +108,8 @@ describe("update", () => {
86
108
write . on ( "finish" , ( ) => {
87
109
resolve ( )
88
110
} )
89
- } ) ,
90
- new Promise ( ( resolve , reject ) => {
91
- const zipFile = new zip ( )
92
- zipFile . addLocalFolder ( archivePath )
93
- zipFile . writeZip ( archivePath + ".zip" , ( error ) => {
94
- return error ? reject ( error ) : resolve ( error )
95
- } )
96
- } ) ,
97
- ] )
98
-
99
- await new Promise ( ( resolve , reject ) => {
100
- server . on ( "error" , reject )
101
- server . on ( "listening" , resolve )
102
- server . listen ( {
103
- port : 0 ,
104
- host : "localhost" ,
105
111
} )
106
- } )
112
+ }
107
113
} )
108
114
109
115
after ( ( ) => {
@@ -205,18 +211,15 @@ describe("update", () => {
205
211
assert . equal ( `console.log("OLD")` , await fs . readFile ( entry , "utf8" ) )
206
212
207
213
// Updating should replace the existing version.
208
- await p . downloadAndApplyUpdate ( update , destination , "linux" )
214
+ await p . downloadAndApplyUpdate ( update , destination )
209
215
assert . equal ( `console.log("UPDATED")` , await fs . readFile ( entry , "utf8" ) )
210
216
211
217
// Should still work if there is no existing version somehow.
212
218
await fs . remove ( destination )
213
- await p . downloadAndApplyUpdate ( update , destination , "linux" )
219
+ await p . downloadAndApplyUpdate ( update , destination )
214
220
assert . equal ( `console.log("UPDATED")` , await fs . readFile ( entry , "utf8" ) )
215
221
216
- assert . deepEqual ( spy , [
217
- "/latest" ,
218
- `/download/${ version } /code-server-${ version } -linux-x86_64.tar.gz` ,
219
- `/download/${ version } /code-server-${ version } -linux-x86_64.tar.gz` ,
220
- ] )
222
+ const archiveName = await p . getReleaseName ( update )
223
+ assert . deepEqual ( spy , [ "/latest" , `/download/${ version } /${ archiveName } ` , `/download/${ version } /${ archiveName } ` ] )
221
224
} )
222
225
} )
0 commit comments