From d5cf4aef4cc551ca88713620c9db77c1ed18f675 Mon Sep 17 00:00:00 2001 From: Max Howell Date: Sat, 22 Apr 2023 10:13:45 -0400 Subject: [PATCH] proper npx fix --- projects/npmjs.com/{npm-shim => npx-shim} | 4 ++-- projects/npmjs.com/package.yml | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) rename projects/npmjs.com/{npm-shim => npx-shim} (74%) diff --git a/projects/npmjs.com/npm-shim b/projects/npmjs.com/npx-shim similarity index 74% rename from projects/npmjs.com/npm-shim rename to projects/npmjs.com/npx-shim index cfd460f4..7a66d8cc 100755 --- a/projects/npmjs.com/npm-shim +++ b/projects/npmjs.com/npx-shim @@ -4,7 +4,7 @@ # FIXME a patch to npm here then upstream would be preferable mkdir -p ~/.local/lib -d="$(cd "$(dirname $0)"/.. && pwd)" -"$d"/tbin/npx "$@" +d="$(cd "$(dirname $0)" && pwd)" +"$d"/npm exec "$@" # ※ https://github.com/teaxyz/cli/issues/532 diff --git a/projects/npmjs.com/package.yml b/projects/npmjs.com/package.yml index fec46ca7..cf93f6c9 100644 --- a/projects/npmjs.com/package.yml +++ b/projects/npmjs.com/package.yml @@ -26,15 +26,19 @@ build: # configures npm to install to ~/.local - mv props/npmrc {{prefix}}/lib/node_modules/npm - # our shim fixes a bug where npm doesn’t work if ~/.local/lib doesn’t exist + # our shim fixes a bug where npx doesn’t work if ~/.local/lib doesn’t exist - run: | - mv ../bin/npm . - mv $SRCROOT/props/npm-shim ../bin/npm + rm npx + mv $SRCROOT/props/npx-shim npx working-directory: - ${{prefix}}/tbin + ${{prefix}}/bin -test: | - npm install --global cowsay - $HOME/.local/bin/cowsay xyz.tea.hi +test: + # doing first to test our shim works as expected + - npx -qy tldr ls + + - npm install --global cowsay + + # verify install location is as we configure it + - $HOME/.local/bin/cowsay xyz.tea.hi - npx -qy tldr ls