link-directories

2.1.0 • Public • Published

link-directories

Link your directories into node_modules so you dont have to do things like require('../../../../foo')

Basically this is what @substack recommends in his browserify-handbook.

usage

Install it

npm i link-directories --save

Add it to postinstall hook in your package.json

Read more about postinstall here: https://docs.npmjs.com/misc/scripts

Let's say you want to require foo.js from lib directory (so basically require('lib/foo.js')), for this add a link-directories entry to your package.json.

{
  "name": "your-module",
  "dependencies": {
     "link-directories": "^1.0.0"
  },
  "scripts": {
    "postinstall": "link-directories"
  },
  "link-directories": [{
    "src": "lib",
    "dest": "node_modules/lib"
  }]
}

Run npm run postinstall

why postinstall?

Because if somebody starts to use your app/project they will git clone your-repo && npm install, so it will just work.

format

currently this module expects an array which contains an object of src and dest. later we should we should add option to use array of strings (which should be interpreted src: <string>, dest: <string>), or set cwd, etc. but first we need to add tests.

license

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.1.0
    0
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.1.0
    0
  • 2.0.0
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i link-directories

Weekly Downloads

0

Version

2.1.0

License

MIT

Last publish

Collaborators

  • lennon
  • oroce
  • ruffle1986