From 8adf943e51ed7edb0ff790caeb94f6a124aedc5e Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Thu, 5 Feb 2015 09:10:10 -0400 Subject: [PATCH] Make use of get-stdin --- lib/helpers/helpers.coffee | 17 ++--------------- package.json | 1 + 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/lib/helpers/helpers.coffee b/lib/helpers/helpers.coffee index 034cbc08..658cf220 100644 --- a/lib/helpers/helpers.coffee +++ b/lib/helpers/helpers.coffee @@ -1,21 +1,8 @@ _ = require('lodash') +getStdin = require('get-stdin') -# TODO: Find a sane way to test streams exports.readStdin = (callback) -> - stdin = process.stdin - - stdin.resume() - stdin.setEncoding('utf8') - - result = [] - - stdin.on('error', callback) - - stdin.on 'data', (chunk) -> - result.push(chunk) - - stdin.on 'end', -> - result = result.join() + getStdin (result) -> return callback(null, result) exports.parseCredentials = (credentials, callback) -> diff --git a/package.json b/package.json index 7cdcf6fc..0be8ff7a 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,7 @@ "conf.js": "^0.1.1", "diskio": "^1.0.0", "drivelist": "^1.1.0", + "get-stdin": "^4.0.1", "git-cli": "~0.8.2", "lodash": "~2.4.1", "lodash-contrib": "~241.4.14",