Sign In

multi-tool

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multi-tool

Install multiple versions of NPM packages as dependencies

Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
3
-88%
Maintainers
1
Weekly downloads
 
Created
Source

multi-tool | Install multiple versions of NPM packages as dependencies

version versioning branching styling paradigm build

Install multiple versions of NPM packages as dependencies at runtime. Use any semver ranges which are also a valid (Li|U)nix directory names as your versions and require them intuitively (e.g. require('ramda@0.23.x'), require('ramda@~0.22.1'), require('ramda@latest')). Leverage custom invalidators to automatically keep installed packages up-to-date.

Install

$ npm install --save multi-tool

Usage

A path to the node_modules directory you wish to install against is required. You will be given a partially applied set of functions upon require that will then act against said path.

const install = require('multi-tool')(path);

Install and use latest version:

const installed = await install('ramda', 'latest'); // 'ramda@latest'
const R = require('ramda@latest');

R.identity(0);

Install and use exact version:

const installed = await install('ramda', '0.23.0'); // 'ramda@0.23.0'
const R = require('ramda@0.23.0');

R.identity(0);

Install and use x-based version:

const installed = await install('ramda', '0.23.x'); // 'ramda@0.23.x'
const R = require('ramda@0.23.x');

R.identity(0);

Install and use tilde-based version:

const installed = await install('ramda', '~0.22.1'); // 'ramda@~0.22.1'
const R = require('ramda@~0.22.1');

R.identity(0);

Install invalid package:

const installed = await install('package-doesnt-exist', 'latest'); // ''

Install invalid version:

const installed = await install('ramda', '99.99.99'); // ''

Custom invalidators (optional):

It is possible to use custom invalidators to customize when multi-tool should assume an already successfully installed package should be reinstalled. This is accomplished via a higher-order function passed as an argument upon require. The invalidator function is executed upon each install. The invalidator function is provided the package name, the package version, and how many milliseconds ago the package at hand was last successfully installed. The invalidator function should return a Boolean value which when true will invalidate the previously successfully installed package and reinstall. The default invalidator will always invalidate (i.e. every install reinstalls the package).

Invalidate always:

const invalidator = (name, version, ago) => ago >= 0;
const install = require('multi-tool')(path, invalidator);

Invalidate never:

const invalidator = (name, version, ago) => ago >= Number.MAX_SAFE_INTEGER;
const install = require('multi-tool')(path, invalidator);

Invalidate only latest versions and only after 10 minutes:

const invalidator = (name, version, ago) => version === 'latest' && ago >= 10000;
const install = require('multi-tool')(path, invalidator);

Maintainers

  • Rocky Madden (@rockymadden)

Keywords

install

FAQs

Package last updated on 06 Mar 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts