Created
September 14, 2013 17:20
-
-
Save kristjanmik/6563816 to your computer and use it in GitHub Desktop.
Restart titanium build on file change
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 chokidar = require('chokidar'), | |
spawn = require('child_process').spawn, | |
utils = require('util'); | |
var watcher = chokidar.watch('./', {ignored: /^build/, persistent: true}); | |
var lastUpdate = new Date().getTime(); | |
function update(path){ | |
if(typeof path === 'object' || path.indexOf('Resources') !== -1 || path.indexOf('build') !== -1 || path.indexOf('monitor.js') !== -1){ | |
return; | |
} | |
var now = new Date().getTime(); | |
if(now-lastUpdate > 3000){ | |
lastUpdate = new Date().getTime(); | |
console.log('File is: ', path); | |
var titanium = spawn('titanium', ['build','-p','ios']); | |
titanium.stdout.on('data', function (data) { | |
utils.log(data); | |
}); | |
titanium.stderr.on('data', function (data) { | |
utils.log(data); | |
}); | |
titanium.on('close', function (code) { | |
utils.log('TITANIUM KILLED, EXIT CODE: ' + code); | |
}); | |
} | |
} | |
watcher | |
.on('add', update) | |
.on('change', update) | |
.on('unlink', update); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment