-
Notifications
You must be signed in to change notification settings - Fork 0
/
msxLogic.js
43 lines (34 loc) · 951 Bytes
/
msxLogic.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
/* jshint node:true */
'using strict';
var fs = require('fs');
var path = require('path');
var through = require('through2');
var gutil = require('gulp-util');
var magenta = gutil.colors.magenta;
var cyan = gutil.colors.cyan;
function msxLogic(options) {
options = options || {};
options.showFiles = typeof options.showFiles === 'string' ?
options.showFiles : (options.showFiles ? 'msx-logic:' : false);
var regex = /\/\*\%|\%\*\//g;
return through.obj(function(file, enc, cb) {
if (file.isNull()) {
this.push(file);
return cb();
}
try {
var str = file.contents.toString();
str = str.replace(regex, '');
} catch(e) {
this.emit('error', e);
return cb();
}
file.contents = new Buffer(str);
if (options.showFiles) {
gutil.log(options.showFiles, magenta(path.relative(file.cwd, file.path)));
}
this.push(file);
cb();
});
}
module.exports = msxLogic;