UNPKG

711 BJavaScriptView Raw
1const readFileNodeback = require('fs').readFile;
2const dirname = require('path').dirname;
3const resolve = require('path').resolve;
4const getStdin = require('get-stdin');
5const globby = require('globby');
6const denodeify = require('denodeify');
7
8const readFile = denodeify(readFileNodeback);
9
10module.exports = input => {
11 if (input.length === 0) {
12 return Promise.resolve(
13 [{
14 content: getStdin.buffer(),
15 directory: process.cwd(),
16 path: process.cwd()
17 }]
18 );
19 }
20 return globby(input)
21 .then(paths => {
22 return paths.map(path => {
23 return {
24 content: readFile(path),
25 directory: dirname(resolve(process.cwd(), path)),
26 path: resolve(process.cwd(), path)
27 };
28 });
29 });
30};