@@ -185,14 +185,18 @@ describe('spawncmd empty env', function(){
185185 assert . strictEqual ( output . stdout . toString ( ) . replace ( '\r' , '' ) , "hi\n" ) ;
186186 /* pwsh */
187187 //windowsVerbatimArguments: true,//for windows? doesnt seem to really do anything
188- output = spawnSync ( pwsh , [ '-Command' , "write-host hi" ] , { shell :false , windowsVerbatimArguments :true , env :{
188+ // output = spawnSync(pwsh,['-Command',"write-host hi"],{ shell:false,windowsVerbatimArguments:true, env:{
189+ // output = spawnSync("C:\\cygwin64\\bin\\printenv.exe",[],{ shell:false,windowsVerbatimArguments:true, env:{
190+ // output = spawnSync("C:\\cygwin64\\bin\\printenv.exe",[],{ shell:false,windowsVerbatimArguments:false, env:{
191+ // output = spawnSync(pwsh,["-Command","ls env:"],{ shell:false,windowsVerbatimArguments:false, env:{
192+ output = spawnSync ( pwsh , [ "-Command" , "(ls env:PATH).value" ] , { shell :false , windowsVerbatimArguments :true , env :{
189193 "PATH" : "c:\\progra~1\\PowerShell\\7;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\System32\\OpenSSH\\" , //enough for echo cmd...
190194 } , } ) ;
191195 // console.log(output);
192- // console.log(output.stderr.toString());
193- // console.log(output.stdout.toString());
196+ console . log ( output . stderr . toString ( ) ) ;
197+ console . log ( output . stdout . toString ( ) ) ;
194198 assert . strictEqual ( output . status , 0 ) ;
195- assert . strictEqual ( output . stdout . toString ( ) . replace ( '\r' , '' ) , "hi\n" ) ;
199+ // assert.strictEqual(output.stdout.toString().replace('\r',''),"hi\n");
196200
197201
198202 // output = spawnSync(pwsh,['dev/node-fs-utils-dev/tests/dev-specific/generate-env-logs.ps1'],options)
@@ -207,6 +211,7 @@ describe('spawncmd empty env', function(){
207211 // const jsonFile = Path.resolve(__dirname,`temp/pwsh-cli.raw.json`);//doesnt work for some reason todo
208212 const jsonFile = Path . resolve ( __filename , `../temp/pwsh-cli.raw.json` ) ;
209213 const txtFile = Path . resolve ( __filename , `../temp/pwsh-cli.txt` ) ;
214+ const ps1File = Path . resolve ( __filename , `../generate-env-logs.ps1` ) ;
210215 if ( fs . existsSync ( jsonFile ) ) {
211216 fs . unlinkSync ( jsonFile )
212217 }
@@ -218,8 +223,28 @@ describe('spawncmd empty env', function(){
218223 const options = {
219224 // shell:true,
220225 shell :false ,
226+ env :{
227+ "PATH" : "c:\\progra~1\\PowerShell\\7;C:\\windows\\system32;C:\\windows;C:\\windows\\System32\\Wbem;C:\\windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\windows\\System32\\OpenSSH\\;C:\\Users\\Jason\\AppData\\Roaming\\nvm\\v16.20.1\\" , //enough for echo cmd...
228+ "NODE_PATH" : "C:\\Users\\Jason\\WebstormProjects\\nuxt3-win32-posix-path\\node_modules\\.pnpm\\node_modules" ,
229+ ...process . env ,
230+ "NODE_FIRST_ARG" :'pwsh-cli' ,
231+ } ,
232+ windowsVerbatimArguments :true ,
233+ }
234+ console . log ( process . env ) ;
235+ if ( ! process . env . NODE_FIRST_ARG ) {
236+ process . env . NODE_FIRST_ARG = options . NODE_FIRST_ARG ;
237+ }
238+ if ( ! process . env . NODE_PATH ) {
239+ process . env . NODE_PATH = options . NODE_PATH ;
240+ }
241+ if ( ! process . env . PATH ) {
242+ process . env . PATH = options . PATH ;
221243 }
222- const output = spawnSync ( pwsh , [ 'dev/node-fs-utils-dev/tests/dev-specific/generate-env-logs.ps1 -NODE_FIRST_ARG "pwsh-cli"' ] , options )
244+ // process.env.NODE_FIRST_ARG = 'pwsh-mocha-cli'
245+ // maybe im just calling powershell wrong lol
246+ // const output = spawnSync(pwsh,['-File','./dev/node-fs-utils-dev/tests/dev-specific/generate-env-logs.ps1'],options)
247+ const output = spawnSync ( pwsh , [ '-File' , ps1File ] , options )
223248 try {
224249
225250 assert . strictEqual ( output . status , 0 ) ;
@@ -230,6 +255,8 @@ describe('spawncmd empty env', function(){
230255 /* ENOENT not found */
231256 throw output . error ;
232257 }
258+ console . log ( output . stdout . toString ( ) ) ;
259+ console . log ( output . stderr . toString ( ) ) ;
233260 assert . ok ( fs . existsSync ( jsonFile ) )
234261 assert . ok ( fs . existsSync ( txtFile ) )
235262 assert . ok ( fs . existsSync ( "dev/node-fs-utils-dev/tests/dev-specific/temp/pwsh-cli.raw.json" ) )
0 commit comments