commit
						2906e8e989
					
				
							
								
								
									
										12
									
								
								cli.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								cli.js
									
									
									
									
									
								
							@ -59,23 +59,15 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    function readStdin() {
 | 
					    function readStdin() {
 | 
				
			||||||
      var text = ''
 | 
					      var text = ''
 | 
				
			||||||
        , timeoutToken
 | 
					 | 
				
			||||||
        , stdin = process.stdin
 | 
					        , stdin = process.stdin
 | 
				
			||||||
        ;
 | 
					        ;
 | 
				
			||||||
      
 | 
					
 | 
				
			||||||
      stdin.resume();
 | 
					      stdin.resume();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // how to tell piping vs waiting for user input?
 | 
					 | 
				
			||||||
      timeoutToken = setTimeout(function () {
 | 
					 | 
				
			||||||
        cb(new Error('no stdin data'));
 | 
					 | 
				
			||||||
        stdin.pause();
 | 
					 | 
				
			||||||
      }, 1000);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      stdin.on('data', function (chunk) {
 | 
					      stdin.on('data', function (chunk) {
 | 
				
			||||||
        clearTimeout(timeoutToken);
 | 
					 | 
				
			||||||
        text += chunk;
 | 
					        text += chunk;
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
      
 | 
					
 | 
				
			||||||
      stdin.on('end', function () {
 | 
					      stdin.on('end', function () {
 | 
				
			||||||
        cb(null, text);
 | 
					        cb(null, text);
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user