function App(config, finalizer){ var self = this this.config = config this.runners = new Backbone.Collection this .on('all-test-results', function () { var allRunnersComplete = self.runners.all(function (runner) { var results = runner.get('results') return results && !!results.get('all') }) if (allRunnersComplete) { self.emit('all-runners-complete') } }) this.exited = false this.paused = false this.finalizer = finalizer || cleanExit this.fileWatcher = fireworm('./', { ignoreInitial: true }) var onFileChanged = this.onFileChanged.bind(this) this.fileWatcher.on('change', onFileChanged) this.fileWatcher.on('add', onFileChanged) this.fileWatcher.on('remove', onFileChanged) this.fileWatcher.on('emfile', this.onEMFILE.bind(this)) // a list of connected browser clients this.runners.on('remove', function(runner){ runner.unbind() }) this.configureView() this.configure(function(){ this.server = new Server(config) this.server.on('server-start', this.initView.bind(this)) this.server.on('file-requested', this.onFileRequested.bind(this)) this.server.on('browser-login', this.onBrowserLogin.bind(this)) this.server.on('server-error', this.onServerError.bind(this)) this.server.start() }) process.on('uncaughtException', function(err){ console.error(err) self.quit(1, err) }) }
#! /usr/bin/env node var fs = require('fs') var fireworm = require('fireworm') var exec = require('child_process').exec var path = require('path') var patterns = process.argv[2] var command = process.argv[3] var basePath = process.cwd() var fw = fireworm(basePath) patterns = patterns.split(',') fw.add.apply(fw, patterns) fw.on('change', function(filepath){ console.log( path.relative(basePath, filepath), 'changed, executing', '"' + command + '"') var p = exec(command) p.stdout.pipe(process.stdout) p.stderr.pipe(process.stderr) p.on('error', function(){}) }) process.nextTick(function(){ console.log('Watching...') })