Created
September 18, 2014 14:51
-
-
Save kristianmandrup/c424528345f9393a364b to your computer and use it in GitHub Desktop.
Optimize local node_modules to symlink to global repo
This file contains 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
Idea for a small *optimize* util to speedup project creation time and keep app footprint low | |
var emberDevDeps = ['body-parser', 'broccoli-asset-rev', | |
'broccoli-ember-hbs-template-compiler', 'ember-cli-ember-data', | |
'ember-cli-ic-ajax', 'ember-cli-ic-ajax', | |
'ember-cli-inject-live-reload', 'ember-cli-qunit express glob' | |
]; | |
$ optimize link --all | |
go through each module dependency in `package.json` via `npm list --depth=0` | |
get list of globally installed modules for those dependencies `npm list <modules referenced> --depth=0` | |
for each one returned, extract name and version in `Repo` object /(.*)@(.*)/ | |
`<name>: [<list of versions>]` | |
for each module dependency | |
get name and version (of exact release versions only, thh like `/(\d{1,2}\.\w+)` - ignore version prefixes for now | |
see if this version (exactly?) matches a globally installed module (lookup in `Repo` object) | |
if so, make a symlink to global module in local /node_modules (via `npm link <module>`) | |
else ignore and continue | |
run `npm install` (it will ignore any local module already symlinked) | |
To remove symlinks, run: | |
$ optimize unlink | |
This should not conflict with the normal npm workflow with respect to updating dependencies... | |
But then again, perhaps too much trouble to implement all this infrastructure to circumvent a basic/standard npm mechanism. I wonder if npm 2.0 dedupe will resolve some of this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment