@@ -23,6 +23,19 @@ test('no shebang', function (t) {
23
23
"\n\"$basedir/from.exe\" \"$@\"\nexit $?\n" )
24
24
t . equal ( fs . readFileSync ( to + '.cmd' , 'utf8' ) ,
25
25
"@\"%~dp0\\from.exe\" %*\r\n" )
26
+ t . equal ( fs . readFileSync ( to + '.ps1' , 'utf8' ) ,
27
+ '#!/usr/bin/env pwsh' +
28
+ '\n$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent' +
29
+ '\n' +
30
+ '\n$exe=""' +
31
+ '\nif ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {' +
32
+ '\n # Fix case when both the Windows and Linux builds of Node' +
33
+ '\n # are installed in the same directory' +
34
+ '\n $exe=".exe"' +
35
+ '\n}' +
36
+ '\n& "$basedir/from.exe" $args' +
37
+ '\nexit $LASTEXITCODE' +
38
+ '\n' )
26
39
t . end ( )
27
40
} )
28
41
} )
@@ -105,6 +118,26 @@ test('env shebang with args', function (t) {
105
118
"\n\"%_prog%\" --expose_gc \"%~dp0\\from.env.args\" %*\r" +
106
119
"\n@ENDLOCAL\r" +
107
120
"\n" )
121
+ t . equal ( fs . readFileSync ( to + '.ps1' , 'utf8' ) ,
122
+ '#!/usr/bin/env pwsh' +
123
+ '\n$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent' +
124
+ '\n' +
125
+ '\n$exe=""' +
126
+ '\nif ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {' +
127
+ '\n # Fix case when both the Windows and Linux builds of Node' +
128
+ '\n # are installed in the same directory' +
129
+ '\n $exe=".exe"' +
130
+ '\n}' +
131
+ '\n$ret=0' +
132
+ '\nif (Test-Path "$basedir/node$exe") {' +
133
+ '\n & "$basedir/node$exe" --expose_gc "$basedir/from.env.args" $args' +
134
+ '\n $ret=$LASTEXITCODE' +
135
+ '\n} else {' +
136
+ '\n & "node$exe" --expose_gc "$basedir/from.env.args" $args' +
137
+ '\n $ret=$LASTEXITCODE' +
138
+ '\n}' +
139
+ '\nexit $ret' +
140
+ '\n' )
108
141
t . end ( )
109
142
} )
110
143
} )
@@ -146,6 +179,26 @@ test('env shebang with variables', function (t) {
146
179
"\n\r" +
147
180
"\n\"%_prog%\" \"%~dp0\\from.env.variables\" %*\r" +
148
181
"\n@ENDLOCAL\r\n" )
182
+ t . equal ( fs . readFileSync ( to + '.ps1' , 'utf8' ) ,
183
+ '#!/usr/bin/env pwsh' +
184
+ '\n$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent' +
185
+ '\n' +
186
+ '\n$exe=""' +
187
+ '\nif ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {' +
188
+ '\n # Fix case when both the Windows and Linux builds of Node' +
189
+ '\n # are installed in the same directory' +
190
+ '\n $exe=".exe"' +
191
+ '\n}' +
192
+ '\n$ret=0' +
193
+ '\nif (Test-Path "$basedir/node$exe") {' +
194
+ '\n & "$basedir/node$exe" "$basedir/from.env.variables" $args' +
195
+ '\n $ret=$LASTEXITCODE' +
196
+ '\n} else {' +
197
+ '\n & "node$exe" "$basedir/from.env.variables" $args' +
198
+ '\n $ret=$LASTEXITCODE' +
199
+ '\n}' +
200
+ '\nexit $ret' +
201
+ '\n' )
149
202
t . end ( )
150
203
} )
151
204
} )
@@ -188,6 +241,27 @@ test('explicit shebang', function (t) {
188
241
"\n\"%_prog%\" \"%~dp0\\from.sh\" %*\r" +
189
242
"\n@ENDLOCAL\r" +
190
243
"\n" )
244
+
245
+ t . equal ( fs . readFileSync ( to + '.ps1' , 'utf8' ) ,
246
+ '#!/usr/bin/env pwsh' +
247
+ '\n$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent' +
248
+ '\n' +
249
+ '\n$exe=""' +
250
+ '\nif ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {' +
251
+ '\n # Fix case when both the Windows and Linux builds of Node' +
252
+ '\n # are installed in the same directory' +
253
+ '\n $exe=".exe"' +
254
+ '\n}' +
255
+ '\n$ret=0' +
256
+ '\nif (Test-Path "$basedir//usr/bin/sh$exe") {' +
257
+ '\n & "$basedir//usr/bin/sh$exe" "$basedir/from.sh" $args' +
258
+ '\n $ret=$LASTEXITCODE' +
259
+ '\n} else {' +
260
+ '\n & "/usr/bin/sh$exe" "$basedir/from.sh" $args' +
261
+ '\n $ret=$LASTEXITCODE' +
262
+ '\n}' +
263
+ '\nexit $ret' +
264
+ '\n' )
191
265
t . end ( )
192
266
} )
193
267
} )
@@ -230,6 +304,27 @@ test('explicit shebang with args', function (t) {
230
304
"\n\"%_prog%\" -x \"%~dp0\\from.sh.args\" %*\r" +
231
305
"\n@ENDLOCAL\r" +
232
306
"\n" )
307
+
308
+ t . equal ( fs . readFileSync ( to + '.ps1' , 'utf8' ) ,
309
+ '#!/usr/bin/env pwsh' +
310
+ '\n$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent' +
311
+ '\n' +
312
+ '\n$exe=""' +
313
+ '\nif ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {' +
314
+ '\n # Fix case when both the Windows and Linux builds of Node' +
315
+ '\n # are installed in the same directory' +
316
+ '\n $exe=".exe"' +
317
+ '\n}' +
318
+ '\n$ret=0' +
319
+ '\nif (Test-Path "$basedir//usr/bin/sh$exe") {' +
320
+ '\n & "$basedir//usr/bin/sh$exe" -x "$basedir/from.sh.args" $args' +
321
+ '\n $ret=$LASTEXITCODE' +
322
+ '\n} else {' +
323
+ '\n & "/usr/bin/sh$exe" -x "$basedir/from.sh.args" $args' +
324
+ '\n $ret=$LASTEXITCODE' +
325
+ '\n}' +
326
+ '\nexit $ret' +
327
+ '\n' )
233
328
t . end ( )
234
329
} )
235
330
} )
0 commit comments