File tree Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Expand file tree Collapse file tree 1 file changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,29 @@ var argv = process.argv.slice(2)
16
16
, semver = require ( "../semver" )
17
17
, reverse = false
18
18
19
- main ( )
19
+ preMain ( )
20
20
21
- function main ( ) {
22
- if ( ! argv . length ) return help ( )
21
+ function preMain ( ) {
22
+ if ( ! process . stdin . isTTY ) {
23
+ process . stdin . setEncoding ( 'utf8' ) ;
24
+
25
+ process . stdin . on ( 'readable' , function ( ) {
26
+ var chunk = process . stdin . read ( ) ;
27
+ if ( chunk !== null ) {
28
+ versions = versions . concat ( chunk . split ( / \s / ) ) ;
29
+ }
30
+ } ) ;
31
+
32
+ process . stdin . on ( 'end' , ( ) => {
33
+ main ( versions . length !== 0 ) ;
34
+ } ) ;
35
+ } else {
36
+ main ( false ) ;
37
+ }
38
+ }
39
+
40
+ function main ( piped ) {
41
+ if ( ! argv . length && ! piped ) return help ( )
23
42
while ( argv . length ) {
24
43
var a = argv . shift ( )
25
44
var i = a . indexOf ( '=' )
@@ -56,6 +75,7 @@ function main () {
56
75
break
57
76
case "-h" : case "--help" : case "-?" :
58
77
return help ( )
78
+ break
59
79
default :
60
80
versions . push ( a )
61
81
break
You can’t perform that action at this time.
0 commit comments