-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
44 lines (39 loc) · 947 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* example-stepup
* http://npmawesome.com/posts/stepup
*
* Copyright(c) 2015 npmawesome.com
*
* MIT Licensed
*/
var stepup = require('stepup');
var fs = require('fs');
stepup([
function ($) {
fs.readdir(__dirname, $.first());
},
function ($, files) {
// pass down the list of files first
$.first()(null, files);
// create a group of `first` type of callbacks
var stats = $.group('first');
for (var i = 0; i < files.length; i++) {
fs.stat(__dirname + '/' + files[i], stats());
}
},
function ($, files, stats) {
var content = $.group('first');
for (var i = 0; i < files.length; i++) {
if (!stats[i].isDirectory()) {
fs.readFile(__dirname + '/' + files[i], content());
}
}
},
function ($, content) {
return content.map(function (buf) {
return buf.toString();
});
}
], function (err, content) {
console.log(content.join('\n-----\n'));
});