Skip to content

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

Open
@imba-tjd

Description

@imba-tjd

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions