nicojs / node-install-local

Installs npm/yarn packages locally without symlink. Exactly the same as your production installation, no compromises.
106 stars 9 forks source link

Possibility to Install without package.json #3

Open vitalets opened 7 years ago

vitalets commented 7 years ago

Hi! Thank you for this library! I'm using it for testing the package I'm developing. Actually I test that it can be correctly installed. I have script that creates temporary directory, installs there from src and runs tests. Currently I need to create dummy package.json because otherwise I'm getting error. Steps:

mkdir -p .installed
echo '{\"name\": \"dummy\"}' > .installed/package.json
pushd .installed
install-local .. 
popd
TEST_PATH=.installed npm run test 

If I don't generate package.json I'm getting the error:

ENOENT: no such file or directory, open '../.installed/package.json'

It would be great to add option to not check package.json presence.

nicojs commented 6 years ago

Hmm i agree that it would be great, but install-local uses npm pack and npm install underneath. This has the benefit of not having to rebuild an actual installation, it just uses an actual npm install.

I guess we could create a fake package.json, do the install and remove it later. It seems kind of hacky, would you like such a solution?

vitalets commented 6 years ago

Yes, creating fake package.json automatically would be great!

nicojs commented 6 years ago

I'm happy to accept a PR for this.

vitalets commented 6 years ago

@nicojs could you please point the place in the code where you think it's better to implement?

nicojs commented 4 years ago

Ow sorry, seems it took me 2,5 years to respond 😅

If you're still interested, I think you're looking for src/currentDirectoryInstall.ts. There we call readPackageJson. I think we can detect the absence of a package.json there and do something different than we're doing now..

vitalets commented 4 years ago

Ow sorry, seems it took me 2,5 years to respond 😅

Never mind! I'm following your awesome work on stryker ;) Concerning this question - I think generating dummy package,json manually is ok as nobody except me came to this issue for 2.5 years.

nicojs commented 3 years ago

Hmm, interesting. Well, that would be a breaking change, since now npm will just walk up until it finds the first package.json and install there. Maybe we should add this behind a --current-directory flag or something?

vitalets commented 3 years ago

Hmm, interesting. Well, that would be a breaking change, since now npm will just walk up until it finds the first package.json and install there. Maybe we should add this behind a --current-directory flag or something?

Currently I'm fine with generating fake package.json manually. I think we should not add more flags/behavior to install-local until strong community request :)