Skip to content

Commit

Permalink
[Fix] allow npx resolve to work
Browse files Browse the repository at this point in the history
Fixes #316.
  • Loading branch information
ljharb committed Sep 15, 2023
1 parent bc01095 commit 1e230d1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions .github/workflows/executable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: resolve executable

on: [push, pull_request]

jobs:
_:
name: cli

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ljharb/actions/node/install@main
- run: "[ $(./bin/resolve fs) = 'fs' ]"
name: run inside the package with a direct path
- run: "npm link && [ $(resolve fs) = 'fs' ] && npm uninstall -g resolve"
name: run linked as a global in the PATH
- run: "[ $(npx resolve fs) = 'fs' ]"
name: run via npx
2 changes: 1 addition & 1 deletion bin/resolve
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if (
!process.argv
|| process.argv.length < 2
|| (process.argv[1] !== __filename && fs.statSync(process.argv[1]).ino !== fs.statSync(__filename).ino)
|| (process.env._ && fs.realpathSync(path.resolve(process.env._)) !== __filename)
|| (process.env.npm_lifecycle_event !== 'npx' && process.env._ && fs.realpathSync(path.resolve(process.env._)) !== __filename)
)
) {
console.error('Error: `resolve` must be run directly as an executable');
Expand Down

0 comments on commit 1e230d1

Please sign in to comment.