Created
September 26, 2014 21:29
-
-
Save fivetanley/02ed075048ab3c63a164 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 watcher = options.watcher; | |
var started = false; | |
var builder = watcher.builder; | |
var oldBuild = builder.build; | |
builder.build = function(){ | |
return this.pausePromise.then(function(){ | |
return oldBuild.apply(this); | |
}.bind(this)); | |
}; | |
//builder.build = require('lodash.debounce')(builder.build, 300); | |
builder.pausePromise = Promise.resolve(); | |
watcher.on('error', function(err){ | |
ui.write('oops', err); | |
ui.write('oops', err.message); | |
process.exit(1); | |
}); | |
function restart(){ | |
var once = require('lodash.once'); | |
builder.pausePromise = new Promise(function(resolve, reject){ | |
testem.app.startTests(function(){ | |
testem.app.on('all-runners-complete', once(resolve)); | |
}); | |
}); | |
} | |
require('osx-ulimit').set(4096); | |
var restartTestem = require('lodash.throttle')(restart, 300); | |
// Wait for a build and then either start or restart testem | |
watcher.on('change', function() { | |
if (started) { | |
restartTestem(); | |
} else { | |
started = true; | |
ui.pleasantProgress.stop(); | |
testem.startDev(testemOptions, function(code) { | |
rimraf(options.outputPath) | |
.finally(function() { | |
process.exit(code); | |
}); | |
}); | |
} | |
}); | |
}).catch(function(err){ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment