Last active
October 13, 2015 15:12
-
-
Save rakeshpai/ac9f71164f3d52f16218 to your computer and use it in GitHub Desktop.
Browserify + Uglify + Espruino using Gulp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require("gulp"), | |
browserify = require("browserify"), | |
source = require("vinyl-source-stream"), | |
buffer = require("vinyl-buffer"), | |
uglify = require("gulp-uglify"), | |
through = require("through2"), | |
port = "/dev/cu.wchusbserial410", | |
espruino = require("node-espruino").espruino({comPort: port}); | |
var upload = through.obj(function(file, enc, done) { | |
if (file.isNull()) return done(null, file); | |
if (file.isStream()) throw new Error('no support'); | |
espruino.open(function() { | |
espruino.upload(file.contents.toString(), {save: true}, function() { | |
espruino.close(function() { | |
done(null, file); | |
}); | |
}); | |
}); | |
}); | |
gulp.task("upload", function() { | |
return browserify({entries: ["./index.js"]}) | |
.bundle() | |
.pipe(source()) | |
.pipe(buffer()) | |
.pipe(uglify()) | |
.pipe(upload); | |
}); | |
gulp.task("default", ["upload"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment