Sindre Sorhus
11 years ago
commit
2f3efbb11d
9 changed files with 124 additions and 0 deletions
@ -0,0 +1,12 @@ |
|||
# editorconfig.org |
|||
root = true |
|||
|
|||
[*] |
|||
indent_style = tab |
|||
end_of_line = lf |
|||
charset = utf-8 |
|||
trim_trailing_whitespace = true |
|||
insert_final_newline = true |
|||
|
|||
[*.md] |
|||
trim_trailing_whitespace = false |
@ -0,0 +1 @@ |
|||
* text=auto |
@ -0,0 +1 @@ |
|||
node_modules |
@ -0,0 +1,19 @@ |
|||
{ |
|||
"node": true, |
|||
"esnext": true, |
|||
"bitwise": true, |
|||
"camelcase": true, |
|||
"curly": true, |
|||
"eqeqeq": true, |
|||
"immed": true, |
|||
"indent": 4, |
|||
"newcap": true, |
|||
"noarg": true, |
|||
"quotmark": "single", |
|||
"regexp": true, |
|||
"undef": true, |
|||
"unused": true, |
|||
"strict": true, |
|||
"trailing": true, |
|||
"smarttabs": true |
|||
} |
@ -0,0 +1,3 @@ |
|||
language: node_js |
|||
node_js: |
|||
- '0.10' |
@ -0,0 +1,15 @@ |
|||
'use strict'; |
|||
module.exports = function (cb) { |
|||
var ret = ''; |
|||
|
|||
process.stdin.resume(); |
|||
process.stdin.setEncoding('utf8'); |
|||
|
|||
process.stdin.on('data', function (data) { |
|||
ret += data; |
|||
}); |
|||
|
|||
process.stdin.on('end', function () { |
|||
cb(ret); |
|||
}); |
|||
}; |
@ -0,0 +1,31 @@ |
|||
{ |
|||
"name": "get-stdin", |
|||
"version": "0.0.0", |
|||
"description": "Easier stdin", |
|||
"license": "MIT", |
|||
"repository": "sindresorhus/get-stdin", |
|||
"author": { |
|||
"name": "Sindre Sorhus", |
|||
"email": "sindresorhus@gmail.com", |
|||
"url": "http://sindresorhus.com" |
|||
}, |
|||
"engines": { |
|||
"node": ">=0.10.0" |
|||
}, |
|||
"scripts": { |
|||
"test": "echo unicorns | mocha" |
|||
}, |
|||
"files": [ |
|||
"index.js" |
|||
], |
|||
"keywords": [ |
|||
"stdin", |
|||
"stdio", |
|||
"concat", |
|||
"buffer", |
|||
"stream" |
|||
], |
|||
"devDependencies": { |
|||
"mocha": "*" |
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
# get-stdin [![Build Status](https://travis-ci.org/sindresorhus/get-stdin.png?branch=master)](https://travis-ci.org/sindresorhus/get-stdin) |
|||
|
|||
> Easier stdin |
|||
|
|||
|
|||
## Install |
|||
|
|||
``` |
|||
npm install --save get-stdin |
|||
``` |
|||
|
|||
|
|||
## Example |
|||
|
|||
```js |
|||
// example.js |
|||
var stdin = require('get-stdin'); |
|||
|
|||
stdin(function (data) { |
|||
console.log(data); |
|||
//=> unicorns |
|||
}); |
|||
``` |
|||
|
|||
``` |
|||
$ echo unicorns | node example.js |
|||
``` |
|||
|
|||
|
|||
## License |
|||
|
|||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
@ -0,0 +1,10 @@ |
|||
'use strict'; |
|||
var assert = require('assert'); |
|||
var stdin = require('./index'); |
|||
|
|||
it('should get stdin', function (cb) { |
|||
stdin(function (data) { |
|||
assert.equal(data.trim(), 'unicorns'); |
|||
cb(); |
|||
}); |
|||
}); |
Loading…
Reference in new issue