- Manage lots of node modules?
- Do you
npm linkmultiple modules together to ensure they all work with latest while developing?
- Find the process of linking together multiple modules tedious?
If you answered YES to all the above, then this module is for you.
Install, then give it a set of directories containing packages that you would like to link together (will parse all immediate subdirectories containing a package.json).
npm install -g symlinksymlink repoDir # prints a list of commands that CAN be executed
To execute these commands in series run symlink by either piping to
sh if pipes are convenient for your use case, or use the
--execute flag which also gives you one log per command.
symlink repoDir --execute
Linking together the related tournament modules from clux's repositories, to ensure they all work together, and all get the same test frameworks (though that's mostly just convenience):
NB: for readability the full paths have been shortened
clux@kjttks ~/trn $ symlink . -g nodeunit -g jscoverage -g nodeunitcd tournament && npm link nodeunit jscoverage coverallscd tournament && npm install interludecd tournament && npm linkcd duel && npm link nodeunit jscoverage coveralls tournamentcd duel && npm install interludecd duel && npm linkcd ffa && npm link nodeunit jscoverage coveralls tournamentcd ffa && npm install interlude groupcd ffa && npm linkcd groupstage && npm link nodeunit jscoverage coveralls tournamentcd groupstage && npm install interlude roundrobin groupcd groupstage && npm linkcd masters && npm link nodeunit jscoverage coveralls tournament ffacd masters && npm install interludecd masters && npm linkcd tiebreaker && npm link nodeunit jscoverage coveralls tournament groupstage ffacd tiebreaker && npm install interludecd tiebreaker && npm linkcd tourney && npm link nodeunit jscoverage coveralls tournamentcd tourney && npm install interludecd tourney && npm linkcd ffa-tb && npm link nodeunit jscoverage coveralls tourney tiebreaker ffacd ffa-tb && npm install autonomycd ffa-tb && npm linkcd groupstage-tb && npm link nodeunit jscoverage coveralls tiebreaker groupstage tourneycd groupstage-tb && npm linkcd groupstage-tb-duel && npm link nodeunit jscoverage duel groupstage-tb tourney groupstagecd groupstage-tb-duel && npm install autonomycd groupstage-tb-duel && npm link# all looks sane - execute:$ kjttks@clux ~/repos $ !! | sh
The most independent modules (tournament) gets their missing dependencies installed first, then gets npm linked so the more requiring modules (specific implementations) can npm link in these.
If you have a local/chowned install of node (such that creating links to globally installed modules can be done sans-sudo) then
symlink can execute sudo free too.
What it does
- reads the
package.jsonof each module founds in the given directory and collects their
- figures out which deps are local (present on one of the repoDirs)
- figures out which deps are external (complement)
- orders the modules so that linking can be in a safe order without having to query npmjs.org more than necessary
Once everything has been ordered, a bunch of commands are generated for each module from the order of least inclusion;
npm link (localDeps) ∪ ((globals ∩ externalDeps))
npm install (externalDeps ∖ globals)
I.e. link in all locally available dependencies + extenal globals that were requested explicitly, install the rest, then link the module itself so the modules with more inclusions can safely link the module in.
Globally linked modules
Test dependencies are often the same everywhere, and, to save querying npmjs, you could just give them the version you have installed (provided it is compatible, and installed globally):
In the example above, every module that uses
coveralls will get the relevant modules linked in.
MIT-Licensed. See LICENSE file for details.