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

squirrel

v1.0.0

Published

A furry little helper for dealing with optional NPM dependencies

Downloads

273

Readme

squirrel

Squirrel is a helpful node module that assists you requiring your dependencies for plugins of your application (version controlled via a custom pluginDependencies in your package.json file).

NPM

Build Status unstable

Why Squirrel?

Because personally, I really don't like the sitting waiting for a node package to install a whole swag of dependencies because it requires them for some functionality that I don't intend to use. I believe using squirrel will enable certain types of packages to have a leaner core with properly managed and installable optional dependencies.

Example Usage

If you are using optionalDependencies in your application, you might consider using pluginDependencies instead and then "squirreling" them rather than requiring them.

NOTE: Squirreling is an asynchronous operation:

var squirrel = require('squirrel');

squirrel('coffee-script', function(err, coffee) {
  // do something magical with coffeescript...
});

If you need multiple modules, then squirrel is happy to play in a way similar to the way AMD module loaders do:

squirrel(['coffee-script', 'jade'], function(err, coffee, jade) {
  // do something with both coffeescript and jade...
});

Different "Allow Install" Modes

Squirrel has been built to support a number of "Allow Install" modes, which is controlled in an allowInstall option that the squirrel function accepts in the 2nd argument, e.g.:

// install jade, and don't trigger a prompt if not already available
squirrel('jade', { allowInstall: true }, function(err, jade) {
});

The default setting for the allowInstall option is set to prompt which means that when a module using squirrel attempts to squirrel one or more modules, the user will be prompted if they want to allow those modules to install. If they don't permit installation then the squirrel operation will fail and an error will be returned in the callback.

Other valid settings for the allowInstall option are true (install dependencies without prompting) or false (always reject module requests).

Other Squirrel Options

A squirrel's got to have options. The demands on the modern squirrel mean that having options is important, and this squirrel is not different. Here are the options that squirrel supports in a 2nd (optional) argument.

  • allowInstall - as outlined above.
  • promptMessage - 'Package "<%= target %>" is required. Permit install? '
  • cwd - the path to squirrel in
  • installer - 'npm'
  • installCommand - '<%= opts.installer %> install <%= target %>@<%= version %>'
  • uninstallCommand - '<%= opts.installer %> rm <%= target %>'

The default options can be modified through modifying them in the squirrel.defaults object.

Shouldn't Squirrel be dependency free?

You could argue that given squirrel's mission is to reduce the overall number of package dependencies, it should be ultralight in it's own packaging. While that's a valid point, I think a balance is required and using existing well-tested libraries is important.

Reference

squirrel(targets, opts?, callback)

Request the installation of the modules specified in the targets array argument.

squirrel.rm(targets, opts, callback)

Remove the specified targets. Used in squirrel tests and I guess in some cases might be useful in production code also.

Squirrel Installer Reference

This module constains the installer helper functions used within squirrel. Each of the functions outlined below is designed to be called initially with an options object, which then provides you the function signature outlined in the docs.

var installer = require('squirrel/installer');

install(target, callback)

Use npm to install the required target.

prepare(target, callback)

This is the first step called in the pull-stream when squirrel is asked for particular modules. It will determine what action is required based on what has been asked for, depending on a number of factors:

  • whether the module requested is relative (i.e. starts with a dot)
  • what our allowed install options (prompt, always, never, etc)
  • whether the module is already available or not

remove(target, callback)

Execute the required installer operation

License(s)

MIT

Copyright (c) 2014 Damon Oehlman [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.