-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.js
More file actions
50 lines (42 loc) · 1.17 KB
/
examples.js
File metadata and controls
50 lines (42 loc) · 1.17 KB
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
'use strict';
var path = require('path');
var util = require('util');
var placeholders = require('placeholders');
var obj = require('./support/configs');
var Files = require('./');
var config = new Files();
function permalinks(data) {
var interpolate = placeholders({data: data});
return function fn(val) {
if (!val.filesNode) return fn;
var data = path.parse(val.src[0]);
val.dest = interpolate(val.dest, data);
console.log(val.dest)
}
}
config.use(permalinks());
var res = [];
obj.forEach(function(val) {
val.examples.forEach(function(example) {
config.expand.apply(config, arrayify(example.config));
// console.log(config.files)
// res.push.apply(res, config.files);
});
});
function arrayify(val) {
return Array.isArray(val) ? val : [val];
}
var config = new Files();
function addFoo(config) {
return function fn(node) {
if (!node.filesNode) return fn;
// return the plugin function if it's not a filesNode
// this way we know with certainty that `node`
// will be a filesNode
node.options.foo = 'bar';
node.dest = 'baz/';
node.abc = 'xyz';
};
}
config.use(addFoo);
console.log(config.expand({src: '*.js'}).files);