Coder Social home page Coder Social logo

link-package's Introduction

link-package

No more require("./../../../../../../../../some/other/file.js").

In large node.js applications, relative require() can be really annoying. You probably already know code like this:

var moduleA = require("./../../../../../../../../path/to/moduleA.js");
var moduleB = require("./../../../../../../../../path/to/moduleB.js");
var moduleC = require("./../../../../../../../../path/to/moduleC.js");

This module allows you to write code like this:

var moduleA = require("your-app/path/to/moduleA.js");
var moduleB = require("your-app/path/to/moduleB.js");
var moduleC = require("your-app/path/to/moduleC.js");

link-package just creates a symlink in your project's node_modules pointing to your project folder (or a sub-folder).


Installation

npm status


Usage

You can use link-package in two ways:

Add this to the scripts-section of your package.json:

"scripts": {
    ...
    "prestart": "link-package",
    "pretest": "link-package",
    ...
}

This will create the symlink before you run npm start or npm test.

Subfolders: If you want the symlink to point to a subfolder like app or lib you can also pass an argument to link-package:

    "prestart": "link-package app",
    "pretest": "link-package app",

node API

If you don't want to use npm scripts you can also use the node API like this:

var linkPackage = require("link-package");

linkPackage();
// or if you want to link a subfolder
linkPackage("app");

You don't need to check if there is already a symlink, link-package does that for you.


Compatibility

Against popular beliefs, symlinks are well supported on Windows.


License

Unlicense

link-package's People

Contributors

jhnns avatar ryardley avatar

Watchers

James Cloos avatar  avatar

Forkers

marketplacer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.