Skip to content

Commit 93e6599

Browse files
committed
docs: stub out deps option
1 parent 9f06c86 commit 93e6599

File tree

4 files changed

+64
-11
lines changed

4 files changed

+64
-11
lines changed

README.md

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,59 @@ List the Node.js versions supported by the package/repository
55
## Usage (command line)
66

77
```
8-
$ npx detect-node-support [path]
8+
$ npx detect-node-support [options] <path>
99
```
1010

1111
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.
1212

1313
When `path` is omitted, tries to detect the versions for `cwd`.
1414

1515
```
16-
$ npx detect-node-support [package name]
16+
$ npx detect-node-support [options] <package name>
1717
```
1818

1919
Prints supported Node.js versions for the package from the registry.
2020

2121
```
22-
$ npx detect-node-support [repository git URL]
22+
$ npx detect-node-support [options] <repository git URL>
2323
```
2424

2525
Prints supported Node.js versions for the package at the git URL.
2626

27+
### Options
28+
29+
* `--deps` - include the support information of all dependencies
30+
2731
## Usage (library)
2832

2933
```
30-
const result = await require('detect-node-support').detect({ path });
34+
const result = await require('detect-node-support').detect({ path }, options);
3135
```
3236

3337
`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.
3438

3539
```
36-
const result = await require('detect-node-support').detect({ packageName });
40+
const result = await require('detect-node-support').detect({ packageName }, options);
3741
```
3842

3943
`packageName` is a string name for the package in the registry.
4044

4145
```
42-
const result = await require('detect-node-support').detect({ repository });
46+
const result = await require('detect-node-support').detect({ repository }, options);
4347
```
4448

4549
`repository` is a URL for a git repository.
4650

51+
```
52+
const result = await require('detect-node-support').detect(what, options);
53+
```
54+
55+
`what` is a string containing either a package name, or a local path, or a reference to a git repository.
56+
57+
### Options
58+
59+
- `deps: false` - when `true`, include the support information of all dependencies.
60+
4761
### Result
4862

4963
- Throws if the `path` / `repository` does not have a `package.json`
@@ -88,6 +102,30 @@ const result = {
88102
"lts/*": "12.14.0",
89103
"invalid-specifier": false
90104
}
105+
},
106+
107+
// only present when explicitly requested
108+
"dependencies": {
109+
110+
// will contain a support object for every unique dependency in the tree
111+
// note that the `version` will be the _latest_ version available in the registry
112+
// see below for the actual versions installed
113+
"support": [
114+
{
115+
"name": "dependency-A"
116+
/*... other fields ...*/
117+
},
118+
{
119+
"name": "dependency-B"
120+
/*... other fields ...*/
121+
}
122+
],
123+
124+
// will contain a list of unique versions for each dependency found in the dependency tree
125+
"versions": {
126+
"dependency-A": ["0.0.10", "1.2.5"],
127+
"dependency-B": ["0.5.3", "1.0.0"]
128+
}
91129
}
92130
}
93131
```

bin/detect-node-support

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,38 @@
22

33
'use strict';
44

5+
const Minimist = require('minimist');
6+
57
const NodeSupport = require('..');
68

79
const internals = {};
810

911
internals.help = () => {
1012

11-
return `Usage: detect-node-support [ path | Github URL | npm package name ]`;
13+
return `
14+
Usage: detect-node-support [--deps] <what>
15+
16+
<what> can be an npm package name, or a Github URL, or a path
17+
with a package.json.
18+
19+
Options:
20+
--deps Include the support information of all dependencies
21+
`;
1222
};
1323

14-
exports.main = async ([nodeBin, thisBin, what]) => {
24+
exports.main = async ({ _: [what], deps }) => {
1525

1626
if (!what) {
1727
console.log(internals.help());
1828
return;
1929
}
2030

21-
const result = await NodeSupport.detect(what);
31+
const result = await NodeSupport.detect(what, { deps });
2232

2333
console.log(result);
2434
};
2535

26-
exports.main(process.argv)
36+
exports.main(Minimist(process.argv.slice(2), { boolean: 'deps' }))
2737
.catch((err) => {
2838

2939
console.error(err);

lib/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
'use strict';
22

3+
const Assert = require('assert');
4+
35
const Engines = require('./engines');
46
const Package = require('./package');
57
const Travis = require('./travis');
68

7-
exports.detect = async function (what) {
9+
exports.detect = async function (what, { deps } = {}) {
10+
11+
Assert.ok(!deps, '`deps` support not implemented yet');
812

913
const packageInfo = await Package.detect(what);
1014

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@pkgjs/nv": "0.0.3",
4141
"git-url-parse": "^11.1.2",
4242
"js-yaml": "^3.13.1",
43+
"minimist": "^1.2.5",
4344
"pacote": "^11.1.0",
4445
"simple-git": "^1.131.0"
4546
}

0 commit comments

Comments
 (0)