1 | const readFileNodeback = require('fs').readFile;
|
2 | const dirname = require('path').dirname;
|
3 | const resolve = require('path').resolve;
|
4 | const getStdin = require('get-stdin');
|
5 | const globby = require('globby');
|
6 | const denodeify = require('denodeify');
|
7 |
|
8 | const readFile = denodeify(readFileNodeback);
|
9 |
|
10 | module.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 | };
|