-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
50 lines (42 loc) · 1.08 KB
/
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
45
46
47
48
49
50
/*
* Gulp-OZJS: gulp task for ozma
*
* Copyright (C) 2014, Keith Yao, MIT License
* vim: et:ts=2:sw=2:sts=2
*/
var gutil, ozma, path, print, root, through;
print = console.log;
path = require('path');
root = path.resolve(__dirname, '../example');
ozma = require('ozma').ozma;
gutil = require('gulp-util');
through = require('through2');
module.exports = function(opts) {
return through.obj(function(file, enc, callback) {
var contents, onWrite;
if (!file.isBuffer()) {
this.push(file);
return callback();
}
contents = file.contents.toString('utf8');
onWrite = (function(_this) {
return function(output, output_code, output_mods, successCallback) {
var joinedFile;
joinedFile = new gutil.File({
base: opts.distUrl,
path: output,
contents: new Buffer(output_code)
});
_this.push(joinedFile);
return successCallback();
};
})(this);
return ozma({
pipe: onWrite,
success: callback
}).exec({
config: opts,
_: [file.path]
}, callback);
});
};