Fix npx failing without ~/.local/lib

Fixes https://github.com/teaxyz/cli/issues/532
This commit is contained in:
Max Howell 2023-04-22 08:41:32 -04:00
parent 6f5ba66dd2
commit baf044ad07
No known key found for this signature in database
GPG key ID: 741BB84EF5BB9EEC
2 changed files with 25 additions and 6 deletions

10
projects/npmjs.com/npm-shim Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
# or npx fails ※
# FIXME a patch to npm here then upstream would be preferable
mkdir -p ~/.local/lib
d="$(cd "$(dirname $0)"/.. && pwd)"
"$d"/tbin/npx "$@"
# ※ https://github.com/teaxyz/cli/issues/532

View file

@ -15,14 +15,23 @@ dependencies:
build: build:
dependencies: dependencies:
crates.io/semverator: '*' crates.io/semverator: '*'
script: | script:
if semverator satisfies '^8,>=9.4.2' {{ version }}; then - |
ARGS="--install-links" if semverator satisfies '^8,>=9.4.2' {{ version }}; then
fi ARGS="--install-links"
fi
node . install --global --prefix={{prefix}} $ARGS - node . install --global --prefix={{prefix}} $ARGS
mv props/npmrc {{prefix}}/lib/node_modules/npm # configures npm to install to ~/.local
- mv props/npmrc {{prefix}}/lib/node_modules/npm
# our shim fixes a bug where npm doesnt work if ~/.local/lib doesnt exist
- run: |
mv ../bin/npm .
mv $SRCROOT/props/npm-shim ../bin/npm
working-directory:
${{prefix}}/tbin
test: | test: |
npm install --global cowsay npm install --global cowsay