feat(nodeenv): install local packages from a requirements file - #407
Merged
Merged
Conversation
-r could only be given once and always installed globally, so the list that `freeze -l` writes had no way back in. -r now accepts repeated use, and --local-requirements installs the packages of a file into "node_modules" of the current directory. Global packages go first. npm < 1.0.0 has no -g at all, so a local file is still installed the old way there. #206
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #206.
Problem
-r/--requirementstook a single value: noaction='append', nonargs. Repeating the flag silently kept the last file, with no error and no merge:And
install_packages()always installed globally (npm install -g), with no option anywhere in--helpasking for a local install. The gap is visible from the other side too:freeze -lwas added for #71 and is documented in the README, so nodeenv could produce a list of locally installed packages but not install one. The file it printed, fed back through-r, installed globally.Change
-r/--requirementsmay be given more than once; files are read in the order given.--local-requirements, also repeatable, installs the packages of a file without-g, intonode_modulesof the directory nodeenv was invoked from. That is the directoryfreeze -lwas run from, and the one node resolves from when the project runs.-r filebehaves exactly as before, andrequirementsis not aConfigattribute, so~/.nodeenvrc,tox.iniandsetup.cfgare unaffected. The--updatepath needed no change: it callsinstall_packages()directly, which now handles both lists.The npm < 1.0.0 branch (
npm install+npm activate) is left alone - it has no-gto drop, so a local file is still installed the old way there. Noted inCHANGES.Tests
install_packages()had no test at all. Four new ones cover the repeated-r, the new flag, and the generated npm commands (-gpresent for global files in file order, absent for local ones, locals last).Verified on a real environment as well:
nodeenv --node=system -r glob.txt --local-requirements loc.txt envputsleft-padinenv/lib/node_modulesandmimein./node_modules;freezeandfreeze -lin that environment then print the two lists back.