forked from josuerios/gulp-angular-translate-module-part
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (29 loc) · 772 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
/**
* Created by Josue on 1/7/16.
*/
var gutil = require('gulp-util');
var path = require('path');
var through = require('through2');
function partialize(options) {
var subfolder = options.subfolder || '';
return through.obj(function transform(file, enc, callback) {
var self = this;
var filePath = file.path.replace(file.cwd, '.');
var splitted = filePath.split(path.sep);
if (subfolder) {
var subPos = splitted.indexOf(subfolder);
if (subPos > -1) {
splitted.splice(subPos, 1);
}
}
// Delete file name;
var filename = splitted.pop();
var folder_name = splitted.pop();
self.push(new gutil.File({
path: path.join(folder_name, filename),
contents: file.contents
}));
callback();
});
}
module.exports = partialize;