forked from insin/msx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
40 lines (33 loc) · 950 Bytes
/
gulpfile.js
File metadata and controls
40 lines (33 loc) · 950 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
37
38
39
40
var gulp = require('gulp')
var msx = require('./main')
var through = require('through2')
var plumber = require('gulp-plumber')
var gutil = require('gulp-util')
var testJSX = './test/jsx/*.jsx'
function msxTransform(options) {
return through.obj(function (file, enc, cb) {
try {
file.contents = new Buffer(msx.transform(file.contents.toString(), options))
file.path = gutil.replaceExtension(file.path, '.js')
this.push(file)
}
catch (err) {
err.fileName = file.path
this.emit('error', new gutil.PluginError('msx', err))
}
cb()
})
}
gulp.task('msx', function() {
return gulp.src(testJSX)
.pipe(plumber())
.pipe(msxTransform({harmony: true}))
.on('error', function(e) {
console.error(e.message + '\n in ' + e.fileName)
})
.pipe(gulp.dest('./test/js/'))
})
gulp.task('watch', function() {
gulp.watch([testJSX], ['msx'])
})
gulp.task('default', ['watch', 'msx'])