Skip to content
forked from clux/symlink

npm link together local modules && npm install remaining dependencies

License

Notifications You must be signed in to change notification settings

RedSeal-co/symlink

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

symlink

npm status build status dependency status coverage status

  • Manage lots of node modules?
  • Do you npm link multiple 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.

Usage

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 symlink
symlink repoDir # prints a list of commands

Execute

To execute these commands in series run symlink with the --execute flag (to get a log per command) or pipe to sh for hardcore mode.

symlink repoDir --execute

Example

Linking together the related tournament modules from clux's repositories, to ensure they all work together:

NB: for readability the full paths have been shortened

clux@kjttks ~/trn $ symlink . -g nodeunit -g jscoverage -g nodeunit
cd tournament && npm link nodeunit jscoverage coveralls
cd tournament && npm install interlude
cd tournament && npm link
cd duel && npm link nodeunit jscoverage coveralls tournament
cd duel && npm install interlude
cd duel && npm link
cd ffa && npm link nodeunit jscoverage coveralls tournament
cd ffa && npm install interlude group
cd ffa && npm link
cd groupstage && npm link nodeunit jscoverage coveralls tournament
cd groupstage && npm install interlude roundrobin group
cd groupstage && npm link
cd masters && npm link nodeunit jscoverage coveralls tournament ffa
cd masters && npm install interlude
cd masters && npm link
cd tiebreaker && npm link nodeunit jscoverage coveralls tournament groupstage ffa
cd tiebreaker && npm install interlude
cd tiebreaker && npm link
cd tourney && npm link nodeunit jscoverage coveralls tournament
cd tourney && npm install interlude
cd tourney && npm link
cd ffa-tb && npm link nodeunit jscoverage coveralls tourney tiebreaker ffa
cd ffa-tb && npm install autonomy
cd ffa-tb && npm link
cd groupstage-tb && npm link nodeunit jscoverage coveralls tiebreaker groupstage tourney
cd groupstage-tb && npm link
cd groupstage-tb-duel && npm link nodeunit jscoverage duel groupstage-tb tourney groupstage
cd groupstage-tb-duel && npm install autonomy
cd 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.json of each module founds in the given directory and collects their dependencies and devDependencies
  • 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)
  • npm link

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

In the example above, every module that uses jscoverage, nodeunit or coveralls will get the relevant modules linked in.

License

MIT-Licensed. See LICENSE file for details.

About

npm link together local modules && npm install remaining dependencies

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%