diff --git a/jsfmt.js b/jsfmt.js index b9c145e..e3ede72 100644 --- a/jsfmt.js +++ b/jsfmt.js @@ -4,7 +4,7 @@ var stdin = require('get-stdin'); var jsfmt = require('jsfmt'); var extend = require('extend'); -stdin().then(function(data) { +stdin(function(data) { var scope = process.argv[3]; var conf = jsfmt.getConfig(); var optsJSON = extend({}, conf, JSON.parse(process.argv[4])); diff --git a/node_modules/get-stdin/index.js b/node_modules/get-stdin/index.js index 2083294..0f1aeb3 100644 --- a/node_modules/get-stdin/index.js +++ b/node_modules/get-stdin/index.js @@ -1,52 +1,49 @@ 'use strict'; -var stdin = process.stdin; -module.exports = function () { +module.exports = function (cb) { + var stdin = process.stdin; var ret = ''; - return new Promise(function (resolve) { - if (stdin.isTTY) { - resolve(ret); - return; - } + if (stdin.isTTY) { + setImmediate(cb, ''); + return; + } - stdin.setEncoding('utf8'); + stdin.setEncoding('utf8'); - stdin.on('readable', function () { - var chunk; + stdin.on('readable', function () { + var chunk; - while ((chunk = stdin.read())) { - ret += chunk; - } - }); + while (chunk = stdin.read()) { + ret += chunk; + } + }); - stdin.on('end', function () { - resolve(ret); - }); + stdin.on('end', function () { + cb(ret); }); }; -module.exports.buffer = function () { +module.exports.buffer = function (cb) { + var stdin = process.stdin; var ret = []; var len = 0; - return new Promise(function (resolve) { - if (stdin.isTTY) { - resolve(new Buffer('')); - return; - } + if (stdin.isTTY) { + setImmediate(cb, new Buffer('')); + return; + } - stdin.on('readable', function () { - var chunk; + stdin.on('readable', function () { + var chunk; - while ((chunk = stdin.read())) { - ret.push(chunk); - len += chunk.length; - } - }); + while (chunk = stdin.read()) { + ret.push(chunk); + len += chunk.length; + } + }); - stdin.on('end', function () { - resolve(Buffer.concat(ret, len)); - }); + stdin.on('end', function () { + cb(Buffer.concat(ret, len)); }); }; diff --git a/node_modules/get-stdin/license b/node_modules/get-stdin/license deleted file mode 100644 index 654d0bf..0000000 --- a/node_modules/get-stdin/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/node_modules/get-stdin/package.json b/node_modules/get-stdin/package.json index 55badf1..f44b437 100644 --- a/node_modules/get-stdin/package.json +++ b/node_modules/get-stdin/package.json @@ -1,7 +1,7 @@ { "name": "get-stdin", - "version": "5.0.0", - "description": "Get stdin as a string or buffer", + "version": "4.0.1", + "description": "Easier stdin", "license": "MIT", "repository": { "type": "git", @@ -10,13 +10,13 @@ "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" + "url": "http://sindresorhus.com" }, "engines": { - "node": ">=0.12.0" + "node": ">=0.10.0" }, "scripts": { - "test": "xo && ava test.js test-buffer.js && echo unicorns | ava test-real.js" + "test": "node test.js && node test-buffer.js && echo unicorns | node test-real.js" }, "files": [ "index.js" @@ -29,38 +29,36 @@ "buffer", "stream", "process", - "read" + "stream" ], "devDependencies": { - "ava": "*", - "buffer-equals": "^1.0.3", - "xo": "*" + "ava": "0.0.4", + "buffer-equal": "0.0.1" }, - "gitHead": "3847c3da6c8c78b8edcc12dd41c8a754a92d664c", + "gitHead": "65c744975229b25d6cc5c7546f49b6ad9099553f", "bugs": { "url": "https://github.com/sindresorhus/get-stdin/issues" }, "homepage": "https://github.com/sindresorhus/get-stdin", - "_id": "get-stdin@5.0.0", - "_shasum": "92ac421f64f6c12a1f9612c092fbd661989272d3", - "_from": "get-stdin@>=5.0.0 <6.0.0", - "_npmVersion": "2.11.3", - "_nodeVersion": "0.12.7", + "_id": "get-stdin@4.0.1", + "_shasum": "b968c6b0a04384324902e8bf1a5df32579a450fe", + "_from": "get-stdin@>=4.0.0 <5.0.0", + "_npmVersion": "1.4.28", "_npmUser": { "name": "sindresorhus", "email": "sindresorhus@gmail.com" }, - "dist": { - "shasum": "92ac421f64f6c12a1f9612c092fbd661989272d3", - "tarball": "http://registry.npmjs.org/get-stdin/-/get-stdin-5.0.0.tgz" - }, "maintainers": [ { "name": "sindresorhus", "email": "sindresorhus@gmail.com" } ], + "dist": { + "shasum": "b968c6b0a04384324902e8bf1a5df32579a450fe", + "tarball": "http://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz" + }, "directories": {}, - "_resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-5.0.0.tgz", + "_resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", "readme": "ERROR: No README data found!" } diff --git a/node_modules/get-stdin/readme.md b/node_modules/get-stdin/readme.md index 7b88ab9..bc1d32a 100644 --- a/node_modules/get-stdin/readme.md +++ b/node_modules/get-stdin/readme.md @@ -1,11 +1,11 @@ # get-stdin [![Build Status](https://travis-ci.org/sindresorhus/get-stdin.svg?branch=master)](https://travis-ci.org/sindresorhus/get-stdin) -> Get stdin as a string or buffer +> Easier stdin ## Install -``` +```sh $ npm install --save get-stdin ``` @@ -14,15 +14,15 @@ $ npm install --save get-stdin ```js // example.js -const stdin = require('get-stdin'); +var stdin = require('get-stdin'); -stdin.then(x => { - console.log(x); - //=> 'unicorns' +stdin(function (data) { + console.log(data); + //=> unicorns }); ``` -``` +```sh $ echo unicorns | node example.js unicorns ``` @@ -30,18 +30,14 @@ unicorns ## API -### stdin() +### stdin(callback) Get `stdin` as a string. -Returns a promise. - -### stdin.buffer() +### stdin.buffer(callback) Get `stdin` as a buffer. -Returns a promise. - ## License diff --git a/package.json b/package.json index e243694..a707ad4 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "esformatter-quotes": "^1.0.3", "esformatter-semicolons": "^1.1.1", "extend": "^3.0.0", - "get-stdin": "^5.0.0", + "get-stdin": "^4.0.1", "jsfmt": "^0.5.0" }, "engines": {