@@ -31,7 +31,8 @@ describe("parser", () => {
3131 }
3232
3333 it ( "should parse nothing" , ( ) => {
34- expect ( parse ( [ ] ) ) . toStrictEqual ( { _ : [ ] } ) } )
34+ expect ( parse ( [ ] ) ) . toStrictEqual ( { _ : [ ] } )
35+ } )
3536
3637 it ( "should parse all available options" , ( ) => {
3738 expect (
@@ -71,32 +72,31 @@ describe("parser", () => {
7172 "--" ,
7273 "-5" ,
7374 "--6" ,
74- ] ) ) . toEqual (
75- {
76- _ : [ "1" , "2" , "3" , "4" , "-5" , "--6" ] ,
77- auth : "none" ,
78- "builtin-extensions-dir" : path . resolve ( "foobar" ) ,
79- "cert-key" : path . resolve ( "qux" ) ,
80- cert : {
81- value : path . resolve ( "baz" ) ,
82- } ,
83- "extensions-dir" : path . resolve ( "foo" ) ,
84- "extra-builtin-extensions-dir" : [ path . resolve ( "bazzle" ) ] ,
85- "extra-extensions-dir" : [ path . resolve ( "nozzle" ) ] ,
86- help : true ,
87- home : "http://localhost:8080/" ,
88- host : "0.0.0.0" ,
89- json : true ,
90- log : "error" ,
91- open : true ,
92- port : 8081 ,
93- socket : path . resolve ( "mumble" ) ,
94- "user-data-dir" : path . resolve ( "bar" ) ,
95- verbose : true ,
96- version : true ,
97- "bind-addr" : "192.169.0.1:8080" ,
75+ ] ) ,
76+ ) . toEqual ( {
77+ _ : [ "1" , "2" , "3" , "4" , "-5" , "--6" ] ,
78+ auth : "none" ,
79+ "builtin-extensions-dir" : path . resolve ( "foobar" ) ,
80+ "cert-key" : path . resolve ( "qux" ) ,
81+ cert : {
82+ value : path . resolve ( "baz" ) ,
9883 } ,
99- )
84+ "extensions-dir" : path . resolve ( "foo" ) ,
85+ "extra-builtin-extensions-dir" : [ path . resolve ( "bazzle" ) ] ,
86+ "extra-extensions-dir" : [ path . resolve ( "nozzle" ) ] ,
87+ help : true ,
88+ home : "http://localhost:8080/" ,
89+ host : "0.0.0.0" ,
90+ json : true ,
91+ log : "error" ,
92+ open : true ,
93+ port : 8081 ,
94+ socket : path . resolve ( "mumble" ) ,
95+ "user-data-dir" : path . resolve ( "bar" ) ,
96+ verbose : true ,
97+ version : true ,
98+ "bind-addr" : "192.169.0.1:8080" ,
99+ } )
100100 } )
101101
102102 it ( "should work with short options" , ( ) => {
@@ -124,7 +124,7 @@ describe("parser", () => {
124124
125125 process . env . LOG_LEVEL = "trace"
126126 const updated = await setDefaults ( args )
127- expect ( updated ) . toStrictEqual ( {
127+ expect ( updated ) . toStrictEqual ( {
128128 ...updated ,
129129 _ : [ ] ,
130130 log : "trace" ,
@@ -142,7 +142,7 @@ describe("parser", () => {
142142 } )
143143
144144 process . env . LOG_LEVEL = "debug"
145- const defaults = await setDefaults ( args )
145+ const defaults = await setDefaults ( args )
146146 expect ( defaults ) . toEqual ( {
147147 ...defaults ,
148148 _ : [ ] ,
@@ -154,7 +154,7 @@ describe("parser", () => {
154154
155155 process . env . LOG_LEVEL = "trace"
156156 const updated = await setDefaults ( args )
157- expect ( updated ) . toEqual ( {
157+ expect ( updated ) . toEqual ( {
158158 ...defaults ,
159159 _ : [ ] ,
160160 log : "info" ,
@@ -172,7 +172,7 @@ describe("parser", () => {
172172
173173 process . env . LOG_LEVEL = "warn"
174174 const updatedAgain = await setDefaults ( args )
175- expect ( updatedAgain ) . toEqual ( {
175+ expect ( updatedAgain ) . toEqual ( {
176176 ...defaults ,
177177 _ : [ ] ,
178178 log : "trace" ,
@@ -206,7 +206,7 @@ describe("parser", () => {
206206 } )
207207
208208 it ( "should error if the option doesn't exist" , ( ) => {
209- expect ( ( ) => parse ( [ "--foo" ] ) ) . toThrowError ( / U n k n o w n o p t i o n - - f o o / )
209+ expect ( ( ) => parse ( [ "--foo" ] ) ) . toThrowError ( / U n k n o w n o p t i o n - - f o o / )
210210 } )
211211
212212 it ( "should not error if the value is optional" , ( ) => {
@@ -246,28 +246,25 @@ describe("parser", () => {
246246 } )
247247 } )
248248
249- it (
250- "should enforce cert-key with cert value or otherwise generate one" ,
251- async ( ) => {
252- const args = parse ( [ "--cert" ] )
253- expect ( args ) . toEqual ( {
254- _ : [ ] ,
255- cert : {
256- value : undefined ,
257- } ,
258- } )
259- expect ( ( ) => parse ( [ "--cert" , "test" ] ) ) . toThrowError ( / - - c e r t - k e y i s m i s s i n g / )
260- const defaultArgs = await setDefaults ( args )
261- expect ( defaultArgs ) . toEqual ( {
262- _ : [ ] ,
263- ...defaults ,
264- cert : {
265- value : path . join ( paths . data , "localhost.crt" ) ,
266- } ,
267- "cert-key" : path . join ( paths . data , "localhost.key" ) ,
268- } )
269- }
270- )
249+ it ( "should enforce cert-key with cert value or otherwise generate one" , async ( ) => {
250+ const args = parse ( [ "--cert" ] )
251+ expect ( args ) . toEqual ( {
252+ _ : [ ] ,
253+ cert : {
254+ value : undefined ,
255+ } ,
256+ } )
257+ expect ( ( ) => parse ( [ "--cert" , "test" ] ) ) . toThrowError ( / - - c e r t - k e y i s m i s s i n g / )
258+ const defaultArgs = await setDefaults ( args )
259+ expect ( defaultArgs ) . toEqual ( {
260+ _ : [ ] ,
261+ ...defaults ,
262+ cert : {
263+ value : path . join ( paths . data , "localhost.crt" ) ,
264+ } ,
265+ "cert-key" : path . join ( paths . data , "localhost.key" ) ,
266+ } )
267+ } )
271268
272269 it ( "should override with --link" , async ( ) => {
273270 const args = parse ( "--cert test --cert-key test --socket test --host 0.0.0.0 --port 8888 --link test" . split ( " " ) )
@@ -310,7 +307,7 @@ describe("parser", () => {
310307 _ : [ ] ,
311308 } )
312309
313- const defaultArgs = await setDefaults ( args )
310+ const defaultArgs = await setDefaults ( args )
314311 expect ( defaultArgs ) . toEqual ( {
315312 ...defaults ,
316313 _ : [ ] ,
@@ -352,11 +349,11 @@ describe("cli", () => {
352349 } )
353350
354351 it ( "should use existing if inside code-server" , async ( ) => {
355- process . env . VSCODE_IPC_HOOK_CLI = "test"
352+ process . env . VSCODE_IPC_HOOK_CLI = "test"
356353 expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( "test" )
357354
358355 args . port = 8081
359- args . _ . push ( "./file" )
356+ args . _ . push ( "./file" )
360357 expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( "test" )
361358 } )
362359
@@ -370,7 +367,7 @@ describe("cli", () => {
370367 args . port = 8081
371368 await expect ( shouldOpenInExistingInstance ( args ) ) . resolves . toStrictEqual ( "test" )
372369 } )
373-
370+
374371 it ( "should use existing if --new-window is set" , async ( ) => {
375372 args [ "new-window" ] = true
376373 expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
@@ -382,31 +379,28 @@ describe("cli", () => {
382379 expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( "test" )
383380 } )
384381
385- it (
386- "should use existing if no unrelated flags are set, has positional, and socket is active" ,
387- async ( ) => {
388- expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
389-
390- args . _ . push ( "./file" )
391- expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
392-
393- const socketPath = path . join ( testDir , "socket" )
394- await fs . writeFile ( vscodeIpcPath , socketPath )
395- expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
396-
397- await new Promise ( ( resolve ) => {
398- const server = net . createServer ( ( ) => {
399- // Close after getting the first connection.
400- server . close ( )
401- } )
402- server . once ( "listening" , ( ) => resolve ( server ) )
403- server . listen ( socketPath )
382+ it ( "should use existing if no unrelated flags are set, has positional, and socket is active" , async ( ) => {
383+ expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
384+
385+ args . _ . push ( "./file" )
386+ expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
387+
388+ const socketPath = path . join ( testDir , "socket" )
389+ await fs . writeFile ( vscodeIpcPath , socketPath )
390+ expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
391+
392+ await new Promise ( ( resolve ) => {
393+ const server = net . createServer ( ( ) => {
394+ // Close after getting the first connection.
395+ server . close ( )
404396 } )
397+ server . once ( "listening" , ( ) => resolve ( server ) )
398+ server . listen ( socketPath )
399+ } )
405400
406- expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( socketPath )
401+ expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( socketPath )
407402
408- args . port = 8081
409- expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
410- }
411- )
403+ args . port = 8081
404+ expect ( await shouldOpenInExistingInstance ( args ) ) . toStrictEqual ( undefined )
405+ } )
412406} )
0 commit comments