npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

grunt-link

v0.2.3

Published

Grunt task to handle the linking of local dependencies

Downloads

24

Readme

build status

grunt-link

Grunt task to handle the linking of local dependencies.

##Use Case

This task is useful if you have a large app and instead of requiring directories directly that should be their own module you can now develop your modules independently and link them using this task.

This allows you to develop as if it were its own module and if you ever decide to publish your modules you just have to change your package.json and your code does not have to change.

This also allows you develop your modules in isolation with their own respective dependencies and tests.

For example assume you have an app of the following structure.

my-node-app
	-models
		-package.json
	-logger
		-package.json
	-config
		-package.json
	-routes
		-package.json		
	-webapp
		-package.json

You could develop each module in isolation and link them.

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-link

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-link');

Documentation

In each modules package.json add a linkDependencies array which is an array of local modules that need to be linked.


{
    "name": "my-module",
    "version" : "0.0.1",
    "linkDependencies": [
    	"module-a", 
    	"module-b", 
    	"module-c"
   	]
}

To run from the command line you can run grunt link which will link your modules.

###Cyclic Dependencies

When running grunt link will determine the link order of your modules, if it detects cyclic dependencies while determining the link order then it will produce an error.

To prevent the warning for a single module you can add ! to the beginning of the dependency name in the linkDependencies array.


{
    "name": "my-module",
    "version" : "0.0.1",
    "linkDependencies": [
        "!module-a", 
        "module-b", 
        "module-c"
    ]
}

Note you will not be able to directly require the module you will have to require lazily.

ignoreCyclic default false

To prevent this default behavior you can add the following to your grunt.js file.


grunt.initConfig({
    link : {
        ignoreCyclic : true
    }
});

dir

By default grunt-link will look for modules in the same directory as your grunt.js file if you wish to link modules in another directory you can add the following to your grunt.js file.

grunt.initConfig({
    link : {
        dir : "location/of/your/modules"
    }
});

Note dir is relative to to grunt.js file.

install default true

grunt-link will run npm install on each linked module if you wish to just link your modules you can set this option to false.

grunt.initConfig({
    link : {
        install : false
    }
});

clean default true

grunt-link will by default remove the node_modules directory to prevent this set clean to false.

grunt.initConfig({
    link : {
        clean : false
    }
});

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

Release History

2014-07-16 v0.2.2

  • Changed to use npm link when initially linking modules

2014-07-16 v0.2.1

  • Updated package.json for correct repo

2014-07-16 v0.2.0

  • Using symlinks instead of npm link to improve performance.
  • Improved logging.

2012-12-30 v0.0.1 Initial release.

License

Copyright (c) 2012 Doug Martin
Licensed under the MIT license.