@@ -8,13 +8,6 @@ import {WriteStreams} from "./write-streams.js";
88import chalkBase from "chalk" ;
99import chalk from "chalk-template" ;
1010
11- // Fallback for when _arrayKeys is not provided (e.g. tests calling handler() directly without yargs).
12- // The CLI path derives array keys from yargs automatically.
13- const ARRAY_OPTIONS_FALLBACK = new Set ( [
14- "variable" , "unsetVariable" , "remoteVariables" , "device" ,
15- "network" , "volume" , "extraHost" , "manual" , "ignoreSchemaPaths" ,
16- ] ) ;
17-
1811export function splitSemicolonEnvVars ( argv : Record < string , any > , arrayKeys : Set < string > , env : Record < string , string | undefined > ) : void {
1912 for ( const [ envKey , envValue ] of Object . entries ( env ) ) {
2013 if ( ! envKey . startsWith ( "GCL_" ) || envValue == null ) continue ;
@@ -117,10 +110,8 @@ export class Argv {
117110 currentVal . unshift ( pair ) ;
118111 }
119112 } else if ( argv [ argKey ] == null ) {
120- const arrayKeys : Set < string > = argv . _arrayKeys ?? ARRAY_OPTIONS_FALLBACK ;
121- if ( arrayKeys . has ( argKey ) ) {
122- this . map . set ( argKey , value . split ( " " ) ) ;
123- } else if ( value === "true" ) this . map . set ( argKey , true ) ;
113+ // Work around `dotenv.parse` limitation https://github.com/motdotla/dotenv/issues/51#issuecomment-552559070
114+ if ( value === "true" ) this . map . set ( argKey , true ) ;
124115 else if ( value === "false" ) this . map . set ( argKey , false ) ;
125116 else if ( value === "null" ) this . map . set ( argKey , null ) ;
126117 else if ( ! isNaN ( Number ( value ) ) ) this . map . set ( argKey , Number ( value ) ) ;
@@ -160,15 +151,18 @@ export class Argv {
160151 }
161152
162153 get volume ( ) : string [ ] {
163- return this . map . get ( "volume" ) ?? [ ] ;
154+ const val = this . map . get ( "volume" ) ?? [ ] ;
155+ return Array . isArray ( val ) ? val : val . split ( " " ) ;
164156 }
165157
166158 get network ( ) : string [ ] {
167- return this . map . get ( "network" ) ?? [ ] ;
159+ const val = this . map . get ( "network" ) ?? [ ] ;
160+ return Array . isArray ( val ) ? val : val . split ( " " ) ;
168161 }
169162
170163 get extraHost ( ) : string [ ] {
171- return this . map . get ( "extraHost" ) ?? [ ] ;
164+ const val = this . map . get ( "extraHost" ) ?? [ ] ;
165+ return Array . isArray ( val ) ? val : val . split ( " " ) ;
172166 }
173167
174168 get caFile ( ) : string | null {
@@ -188,7 +182,8 @@ export class Argv {
188182 }
189183
190184 get remoteVariables ( ) : string [ ] {
191- return this . map . get ( "remoteVariables" ) ?? [ ] ;
185+ const val = this . map . get ( "remoteVariables" ) ?? [ ] ;
186+ return Array . isArray ( val ) ? val : val . split ( " " ) ;
192187 }
193188
194189 get variable ( ) : { [ key : string ] : string } {
@@ -208,7 +203,8 @@ export class Argv {
208203 }
209204
210205 get manual ( ) : string [ ] {
211- return this . map . get ( "manual" ) ?? [ ] ;
206+ const val = this . map . get ( "manual" ) ?? [ ] ;
207+ return Array . isArray ( val ) ? val : val . split ( " " ) ;
212208 }
213209
214210 get job ( ) : string [ ] {
@@ -241,7 +237,8 @@ export class Argv {
241237 }
242238
243239 get device ( ) : string [ ] {
244- return this . map . get ( "device" ) ?? [ ] ;
240+ const val = this . map . get ( "device" ) ?? [ ] ;
241+ return Array . isArray ( val ) ? val : val . split ( " " ) ;
245242 }
246243
247244 get ulimit ( ) : string | null {
0 commit comments