detect-node-support
List the Node.js versions supported by the package/repository
Usage (command line)
$ npx detect-node-support [options] <path>
Prints the supported Node.js versions for the package at the specified path. When the path is not a git repository - tries to read the git repository from package.json
and tries to detect the versions listed in the repository as well.
When path
is omitted, tries to detect the versions for cwd
.
$ npx detect-node-support [options] <package name>
Prints supported Node.js versions for the package from the registry.
$ npx detect-node-support [options] <repository git URL>
Prints supported Node.js versions for the package at the git URL.
Options
--deep
- when used with --deps, include indirect dependencies--deps
- include the support information of direct production dependencies--dev
- when used with --deps, include dev dependencies
Usage (library)
const result = await require('detect-node-support').detect({ path }, options);
path
should be a folder in the local file system. When the path is not a git repository - tries to read the git repository from package.json
and tries to detect the versions listed in the repository as well.
const result = await require('detect-node-support').detect({ packageName }, options);
packageName
is a string name for the package in the registry.
const result = await require('detect-node-support').detect({ repository }, options);
repository
is a URL for a git repository.
const result = await require('detect-node-support').detect(what, options);
what
is a string containing either a package name, or a local path, or a reference to a git repository.
Options
deep: false
- when true
and used deps: true
, include indirect dependenciesdeps: false
- when true
, include the support information of all dependencies.dev: false
- when true
and used with deps: true
, include dev dependencies
Result
- Throws if the
path
/ repository
does not have a package.json
- Throws if
packageName
does not exist in the registry - Throws when unable to detect a git repository for the package
Otherwise returns an object with:
const result = {
"name": "package-name",
"version": "0.0.0",
"timestamp": 1577115956099,
"commit": "2de28c8c4ab8ac998d403509123736929131908c",
"engines": ">=x.y.z",
"travis": {
"raw": ["8", "10", "lts/*", "invalid-specifier"],
"resolved": {
"8": "8.17.0",
"10": "10.18.0",
"lts/*": "12.14.0",
"invalid-specifier": false
}
},
"dependencies": {
"support": [
{
"name": "dependency-A"
},
{
"name": "dependency-B"
}
],
"versions": {
"dependency-A": ["0.0.10", "1.2.5"],
"dependency-B": ["0.5.3", "1.0.0"],
"dependency-C": ["7.8.9"]
},
"errors": {
"dependency-C": {
"message": "Failed to download some information or something"
}
}
}
}