Closed coolaj86 closed 3 years ago
@janniks I know you're busy, but I've giving this a bump just in a case you have some more time this week and have forgotten about it.
Thanks for the bump! And sorry for the delay — will do some coding on this now.
@janniks You'd asked me to show you how this works, here's a go:
Create a project using basetag (using my fork because I know my exact changes work):
mkdir -p /tmp/example
pushd /tmp/example/
npm init -y
npm install --save 'git+https://github.com/coolaj86/basetag.git#basetag-bin'
Check that the $
exists:
ls -laF /tmp/example/node_modules/\$
/tmp/example/node_modules/$@ ⇒ /private/tmp/example
Install something else (which will destroy $
:
npm install --save @root/request
Check that the $
DOES NOT exist:
ls -laF /tmp/example/node_modules/\$
lsd: /tmp/example/node_modules/$: No such file or directory (os error 2).
Edit that project's package.json
to include a basetag
script:
vim /tmp/example/package.json
{
// ...
"scripts": {
"postinstall": "npx basetag",
"test": "echo \"Error: no test specified\" && exit 1"
},
// ...
}
Now run npm install
again:
npm install
See that the basetag $
exists:
ls -laF /tmp/example/node_modules/\$
/tmp/example/node_modules/$@ ⇒ /private/tmp/example
The bad news is that if we install a specific item, it breaks again until we re-run npm install
, which I had not realized at first:
npm install --save @root/request
Check $
:
ls -laF /tmp/example/node_modules/\$
lsd: /tmp/example/node_modules/$: No such file or directory (os error 2).
Run npm install
again:
npm install
Check $
:
ls -laF /tmp/example/node_modules/\$
/tmp/example/node_modules/$@ ⇒ /private/tmp/example
Got it! This is where my confusion came from — I thought you meant it also works after a specific package install (e.g. npm install --save x
)
I'm working on a solution that could both be used as the postinstall script (as in your branch) but also sets up the .hooks
file to work after a specific package install. Then we would cover all bases and avoid a lot of confusion for new users.
This is important because
npm install
always destroysnode_modules/$
and runningnpm ci
can take minutes.Usage
package.json
:Test my branch