-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
36 lines (31 loc) · 1013 Bytes
/
index.js
File metadata and controls
36 lines (31 loc) · 1013 Bytes
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
/**
* Created by Matthieu on 20/09/2016.
*/
'use strict';
var through = require('through2');
var PluginPath = require('path');
var gutil = require('gulp-util');
var PluginError = gutil.PluginError;
var yaml = require('js-yaml');
var File = require('vinyl');
var fs = require('fs');
module.exports = function() {
return through.obj(function(file, enc, callback) {
var buffer;
var contents = file.contents.toString('utf8');
var ymlDocument = yaml.load(contents);
for(let folder in ymlDocument){
if(ymlDocument.hasOwnProperty(folder)){
for(let path of ymlDocument[folder]){
buffer = fs.readFileSync(path);
var newFile = new File({
path: folder + '/' + PluginPath.basename(path),
contents: buffer
});
this.push(newFile);
}
}
}
callback();
});
};