JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 208
  • Score
    100M100P100Q86532F
  • License MIT

Package Duplicate Detector

Package Exports

  • duplitect

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (duplitect) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

duplitect

travis npm

duplitect is a simple tool to detect duplicate versions of installed packages. JavaScript package managers such as NPM and Yarn habitually allow you to install multiple versions of (transient) dependencies. This works most of the time - for certain kinds of packages, it does not.

untool happens to be among these packages that have to be installed exactly once inside any given project, which is why we built this module.

Installation

Using NPM:

npm install -S duplitect

Using Yarn:

yarn add duplitect

CLI

Usually, you will want to use duplitect as a CLI tool. Since most typical Node.js projects contain a significant number of (unproblematic) duplicates, you will probably want to limit duplitect's output by passing one or more patterns.

Example
$ duplitect untool @untool*
Duplicate: untool
Duplicate: @untool/core

duplitect supports the wildcard character * as shown above. This allows you to match multiple, possibly scoped, packages at once.

API

You can also use duplitect in your own tools - it exposes two functions: one, that mimics the CLI functionality. And a second one, that additionally provides the versions of the duplicates.

getDuplicates(cwd, [pattern, pattern, ...])

const { getDuplicates } = require('duplitect');

const duplicates = getDuplicates(process.cwd(), 'untool', '@untool*');
duplicates.forEach((duplicate) => console.log(`Duplicate: ${duplicate}`));

getDuplicatesDetails(cwd, [pattern, pattern, ...])

const { getDuplicatesDetails } = require('duplitect');

getDuplicatesDetails(process.cwd(), 'untool', '@untool*').then((duplicates) =>
  duplicates.forEach(({ name, version, pathName }) =>
    console.log('name: %s, version: %s, pathName: %s', name, version, pathName)
  )
);