Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Powershell - Windows - Handle node.exe not on path, but node existing similar to cmd shims #51

Open
dsherret opened this issue Feb 16, 2021 · 0 comments

Comments

@dsherret
Copy link

dsherret commented Feb 16, 2021

What / Why

I'm working on a generic binary version manager. Everything works decently well, but I recently ran into trouble with how this package generates powershell shims expecting node.exe on the path for Windows (in my case, only node.cmd and node.ps1 exist on the path).

The cmd shim seems fine and it will fallback to using node instead of node.exe when node.exe doesn't exist (you may categorize this difference between cmd and powershell as a bug).

Current Behavior

Example of yarn's script:

#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent

$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
  # Fix case when both the Windows and Linux builds of Node
  # are installed in the same directory
  $exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
  & "$basedir/node$exe"  "$basedir/node_modules/yarn/bin/yarn.js" $args
  $ret=$LASTEXITCODE
} else {
  & "node$exe"  "$basedir/node_modules/yarn/bin/yarn.js" $args
  $ret=$LASTEXITCODE
}
exit $ret

Expected Behavior

It would do Test-Path for .exe and if that doesn't exist, then it would fallback to not providing a .exe file extension.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant