@@ -23,6 +23,19 @@ test('no shebang', function (t) {
2323 "\n\"$basedir/from.exe\" \"$@\"\nexit $?\n" )
2424 t . equal ( fs . readFileSync ( to + '.cmd' , 'utf8' ) ,
2525 "@\"%~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' )
2639 t . end ( )
2740 } )
2841} )
@@ -105,6 +118,26 @@ test('env shebang with args', function (t) {
105118 "\n\"%_prog%\" --expose_gc \"%~dp0\\from.env.args\" %*\r" +
106119 "\n@ENDLOCAL\r" +
107120 "\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' )
108141 t . end ( )
109142 } )
110143} )
@@ -146,6 +179,26 @@ test('env shebang with variables', function (t) {
146179 "\n\r" +
147180 "\n\"%_prog%\" \"%~dp0\\from.env.variables\" %*\r" +
148181 "\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' )
149202 t . end ( )
150203 } )
151204} )
@@ -188,6 +241,27 @@ test('explicit shebang', function (t) {
188241 "\n\"%_prog%\" \"%~dp0\\from.sh\" %*\r" +
189242 "\n@ENDLOCAL\r" +
190243 "\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' )
191265 t . end ( )
192266 } )
193267} )
@@ -230,6 +304,27 @@ test('explicit shebang with args', function (t) {
230304 "\n\"%_prog%\" -x \"%~dp0\\from.sh.args\" %*\r" +
231305 "\n@ENDLOCAL\r" +
232306 "\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' )
233328 t . end ( )
234329 } )
235330} )
0 commit comments