forked from juancabrera/gulp-traceur-cmdline
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
47 lines (39 loc) · 1.2 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
/*jshint node:true */
'use strict';
var map = require('map-stream'),
gutil = require('gulp-util'),
exec = require('child_process').exec,
fs = require('fs'),
build_commandline = require('./lib/traceur_command_builder');
module.exports = function(opt) {
// Assign default options if one is not supplied
opt = opt || {};
var debug = opt.debug || false;
var clear = opt.clear;
delete opt.debug;
delete opt.clear;
return map( function(file, cb) {
var module_opts = {
clear: clear,
file: file,
traceurcmd: __dirname + "/node_modules/traceur/traceur"
};
var cmd = build_commandline(opt, module_opts);
// print out debug details
if (debug) {
gutil.log(gutil.colors.yellow('\n *** Debug : Command - ' + cmd + ' ***\n'));
}
exec(cmd, function(error, stdout, stderr) {
// call user callback if ano error occurs
if (error) {
if (debug) {
gutil.log(error);
}
cb(error, file);
}
else {
cb(null, file);
}
});
});
};