Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to Install without package.json #3

Open
vitalets opened this issue Oct 31, 2017 · 8 comments
Open

Possibility to Install without package.json #3

vitalets opened this issue Oct 31, 2017 · 8 comments

Comments

@vitalets
Copy link

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
Copy link
Owner

nicojs commented Jan 22, 2018

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
Copy link
Author

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

@nicojs
Copy link
Owner

nicojs commented Jun 20, 2018

I'm happy to accept a PR for this.

@vitalets
Copy link
Author

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

@nicojs
Copy link
Owner

nicojs commented Oct 16, 2020

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
Copy link
Author

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
Copy link
Owner

nicojs commented Apr 20, 2021

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
Copy link
Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants