-
Notifications
You must be signed in to change notification settings - Fork 13
/
expall.js
62 lines (51 loc) · 1.79 KB
/
expall.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* global module, __dirname */
(function () {
'use strict';
var fs = require('fs');
var _ = require('lodash');
var path = require('path');
function notHidden(filename) {
if (filename.indexOf('.') == 0) {
return false;
}
return true;
}
function expall(fulldir) {
var dir = fulldir.replace(/^src\//, '');
var mods = fs.readdirSync(fulldir);
mods = mods.filter(notHidden);
var out = [];
_.each(mods, function (mod) {
out.push("export { default as " + mod + " } from './" + dir + "/" + mod + "/" + mod + "';");
});
fs.writeFileSync(path.join(__dirname, fulldir + '.js'), out.join('\n'));
}
// var walk = require('walk');
// var isDir = require('is-dir');
// var walker;
// walker = walk.walk('src/effects');
// walker.on('file', function (root, fileStats, next) {
// var skip = root.indexOf('src/lib') === 0;
// var matching_dir;
// var is_js;
// if (!skip) {
// // if this is a JS file, and is a sibling to a dir with the same
// // name, repopulate the js file as an exporter of the modules in
// // the matching dir.
// is_js = /\.js$/.test(fileStats.name);
// matching_dir = root + '/' + fileStats.name.replace(/\.js$/, '');
// if (is_js && isDir(matching_dir)) {
// console.log(matching_dir + ':');
// console.log( fs.readdirSync(matching_dir));
// }
// next();
// }
// });
// walker.on('errors', function (root, nodeStatsArray, next) {
// next();
// });
// walker.on('end', function () {
// console.log('all done');
// });
module.exports = expall;
}());