Created
July 7, 2015 03:48
-
-
Save badcc/cb831f023f02a3e04ad8 to your computer and use it in GitHub Desktop.
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 EXEC_FILE_LOCATION = process.argv[2] | |
var LUA_BINARY_NAME = process.argv[3] ? process.argv[3] : 'lua' | |
var chokidar = require('chokidar'); | |
var fs = require('fs'); | |
var http = require('http'); | |
var exec = require('child_process').exec | |
var responses = [] | |
http.createServer(function(req, res) { | |
responses.push(res); | |
}).listen(8888, '0.0.0.0'); | |
var watcher = chokidar.watch(EXEC_FILE_LOCATION + '\\src', { | |
ignored: /[\/\\]\./, | |
persistent: true | |
}); | |
watcher.on('change', function(path) { | |
if (path.indexOf('exec.lua') < 0) { | |
console.log(path + ' changed; bulding...'); | |
exec(LUA_BINARY_NAME + ' "' + EXEC_FILE_LOCATION + '\\build.lua"', function(err, stdout, stderr) { | |
if (err) return console.log(err); | |
fs.readFile(EXEC_FILE_LOCATION + '\\exec.lua', 'utf8', function(err, data) { | |
if (err) return console.log(err); | |
while (responses.length) { | |
var res = responses.shift(); | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end(data); | |
} | |
}) | |
}) | |
} | |
}) | |
console.log('RbxRefresh running.'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment