Skip to content

Instantly share code, notes, and snippets.

@remcoder
Last active June 20, 2016 14:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remcoder/408c1979055810d29e3fbd622c51500a to your computer and use it in GitHub Desktop.
Save remcoder/408c1979055810d29e3fbd622c51500a to your computer and use it in GitHub Desktop.
Fast, incremental Lua uploads for nodemcu
Fast, incremental Lua uploads for NodeMCU
INSTALLATION
1. This script requires nodemcu-uploader and gulp to be installed globally:
$ npm install -g gulp
$ npm install -g nodemcu-tool
$ pip install nodemcu-uploader
2. Then create a directory and copy the files from the gist into it
3. Finally you should install other dependencies by running
$ npm install
CHANGELOG
06/16/2016
- Switched from nodemcu-tool to nodemcu-uploader for 7x faster uploads (but kept the config file)
- Add linting task based on luacheck
{
"baudrate": "115200",
"port": "/dev/cu.SLAB_USBtoUART",
"optimize": false,
"compile": false
}
#!/usr/bin/env bash
echo
echo "Syncing.."
gulp
echo
echo "Rebooting.."
nodemcu-tool --silent run commands/reboot.lua terminal
echo
echo "Starting terminal"
nodemcu-tool --silent terminal
var fs = require('fs');
var gulp = require('gulp');
var shell = require('gulp-shell');
var changed = require('gulp-changed');
var clean = require('gulp-clean');
var luacheck = require("gulp-luacheck");
var SRC = 'src/**/*.lua';
var DEST = 'dist';
// we'll use some settings from nodemcu-tool when uploading with nodemcu-uploader
var nodemcutoolOptions = JSON.parse(fs.readFileSync('.nodemcutool'));
var baudrate = nodemcutoolOptions.baudrate;
var port = nodemcutoolOptions.port;
function upload() {
//shell("nodemcu-tool upload --remotename <%= file.relative %> src/<%= file.relative %>")
return shell("echo uploading <%= file.relative %> ; nodemcu-uploader --port " + port + " --start_baud " + baudrate + " upload src/<%= file.relative %>:<%= file.relative %> > /dev/null 2>&1")
}
gulp.task('default', function() {
var result = gulp.src(SRC, { base: 'src' })
.pipe(changed(DEST))
.pipe(upload())
.pipe(gulp.dest(DEST));
return result;
});
gulp.task('all', function() {
return gulp.src(SRC, { base: 'src' })
.pipe(upload())
.pipe(gulp.dest(DEST));
});
gulp.task('clean', function () {
return gulp.src(DEST, {read: false})
.pipe(clean());
});
gulp.task("lint", function() {
return gulp
.src(SRC)
.pipe(shell("echo linting: <%= file.path %>"))
.pipe(luacheck({
globals: ['tmr', 'ws2812', 'wifi']
}))
.pipe(luacheck.reporter())
});
{
"devDependencies": {
"gulp": "^3.9.1",
"gulp-changed": "^1.3.0",
"gulp-clean": "^0.3.2",
"gulp-luacheck": "^1.0.3",
"gulp-shell": "^0.5.2"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment