Skip to content

Fails to run when .js file assoc is not node #1

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

Open
imba-tjd opened this issue Mar 30, 2023 · 0 comments
Open

Fails to run when .js file assoc is not node #1

imba-tjd opened this issue Mar 30, 2023 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@imba-tjd
Copy link

imba-tjd commented Mar 30, 2023

I just tried on a online Linux VSCode environment. It has the same issue.


the tinyhttp.ps1 tries to execute .js directly. When the file assoc is not node.exe, it fails to execute. For example on my PC, double click .js will open VSCode, so does execute .js in shell.

I have no clue why this happens. Theoretically it's auto generated? BTW I'm using npm, not pnpm

#!/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"
}
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
  $input | & "$basedir/../@tinyhttp/cli/dist/index.js"   $args
} else {
  & "$basedir/../@tinyhttp/cli/dist/index.js"   $args
}
exit $LASTEXITCODE

this is another cli tool

#!/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") {
  # Support pipeline input
  if ($MyInvocation.ExpectingInput) {
    $input | & "$basedir/node$exe"  "$basedir/node_modules/jiti/bin/jiti.js" $args
  } else {
    & "$basedir/node$exe"  "$basedir/node_modules/jiti/bin/jiti.js" $args
  }
  $ret=$LASTEXITCODE
} else {
  # Support pipeline input
  if ($MyInvocation.ExpectingInput) {
    $input | & "node$exe"  "$basedir/node_modules/jiti/bin/jiti.js" $args
  } else {
    & "node$exe"  "$basedir/node_modules/jiti/bin/jiti.js" $args
  }
  $ret=$LASTEXITCODE
}
exit $ret

Versions

  • node: v19.8.1
  • @tinyhttp/cli: 1.3.4
@imba-tjd imba-tjd added the bug Something isn't working label Mar 30, 2023
@imba-tjd imba-tjd changed the title Fails to run on windows Fails to run when .js file assoc is not node Mar 31, 2023
@talentlessguy talentlessguy added the help wanted Extra attention is needed label May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants