@nurun-sf/spark-component
Version:
A tool for building spark components
37 lines (29 loc) • 907 B
JavaScript
;
const comms = require('../lib/comms');
module.exports = function (gulp) {
// Webpack can take longer than PhantomJS to spin up and start the tests, so
// this waits until it's done.
function waitForEvent(name, task) {
return function () {
var timerId;
function ready() {
clearTimeout(timerId);
gulp.start(task);
}
comms.once(name, ready);
// In case webpack was able to complete before we were notified of a file
// change, time out after 2 seconds.
timerId = setTimeout(function () {
comms.removeListener(name, ready);
ready();
}, 2000);
};
}
return function testWatcher() {
gulp.watch('src/**/*.js', waitForEvent('webpacked:source', 'instrument-run'));
gulp.watch([
'tests/**/*.js',
'!tests/**/specs.js',
], waitForEvent('webpacked:specs', 'test-run'));
};
};