File tree Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Expand file tree Collapse file tree 3 files changed +63
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env node
2
+
3
+ 'use strict' ;
4
+
5
+ const Fs = require ( 'fs' ) ;
6
+ const NodeSupport = require ( '..' ) ;
7
+ const { URL } = require ( 'url' ) ;
8
+
9
+
10
+ const internals = { } ;
11
+
12
+
13
+ internals . autoDetect = ( what ) => {
14
+
15
+ if ( ! what ) {
16
+ return NodeSupport . detect ( { path : '.' } ) ;
17
+ }
18
+
19
+ try {
20
+ var url = new URL ( what ) ;
21
+ }
22
+ catch ( err ) {
23
+ if ( err . code !== 'ERR_INVALID_URL' ) {
24
+ throw err ;
25
+ }
26
+ }
27
+
28
+ if ( url ) {
29
+ return NodeSupport . detect ( { repository : url . href } ) ;
30
+ }
31
+
32
+ if ( Fs . existsSync ( what ) ) {
33
+ return NodeSupport . detect ( { path : what } ) ;
34
+ }
35
+
36
+ if ( what . includes ( '/' ) && ! what . startsWith ( '@' ) ) {
37
+ return NodeSupport . detect ( { repository : `https://github.com/${ what } ` } ) ;
38
+ }
39
+
40
+ return NodeSupport . detect ( { packageName : what } ) ;
41
+ } ;
42
+
43
+ exports . main = async ( nodeBin , thisBin , what ) => {
44
+
45
+ const result = await internals . autoDetect ( what ) ;
46
+
47
+ console . log ( result ) ;
48
+ } ;
49
+
50
+ exports . main ( ...process . argv )
51
+ . catch ( ( err ) => {
52
+
53
+ console . error ( err ) ;
54
+ process . exit ( 1 ) ;
55
+ } ) ;
Original file line number Diff line number Diff line change 4
4
"description" : " List the Node.js versions supported by the package/repository" ,
5
5
"main" : " lib/index.js" ,
6
6
"scripts" : {
7
+ "test-cli" : " while read p; do echo \" ./bin/node-support $p\" ; ./bin/node-support $p; done < ./test/cli-test.txt" ,
7
8
"test" : " lab -a @hapi/code -L -p 1 -t 100"
8
9
},
9
10
"repository" : {
Original file line number Diff line number Diff line change
1
+
2
+ .
3
+ node-support
4
+ @hapi/hapi
5
+ pkgjs/node-support
6
+ https://github.com/pkgjs/node-support
7
+ git+https://github.com/pkgjs/node-support.git
You can’t perform that action at this time.
0 commit comments