Skip to content

mapbox/duplicate-module-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Duplicate module test

A small command line utility used to test for duplicate installs of a module or list of modules using NPM's npm ls command output. Particularly helpful for node addons where you want to be 💯 sure there is only a single version of a binary installed before executing your code. More background as to why avoiding duplicate binaries is important here.

Usage

The primary usage is via the CLI command, duplicate-module-test, which assumes every argument passed in is the name of a module in the node_modules tree to test.

Example command

duplicate-module-test @mapbox/vtquery mapnik something-else

Output will look something like:

Checking for duplicate modules ...

✔ @mapbox/vtquery has only one version
✗ found 2 versions of mapnik
✔ something-else has only one version

Pretest

The command is particularly helpful added as a pretest command in your package.json document. This can be run in tandem with other pretest commands, like linters.

{
  "scripts": {
    "test": "node tests.js",
    "pretest": "duplicate-module-test module-one module-two && eslint index.js"
  }
}

About

Test for duplicate installs of a node module(s)

Topics

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published