From b3c462a5abd67aa041570d5ff974c0fb9d930e76 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Fri, 17 Jul 2015 23:18:41 +0200 Subject: [PATCH] feat(server): Add public api to force a file list refresh. --- docs/dev/04-public-api.md | 8 ++++++++ lib/server.js | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/docs/dev/04-public-api.md b/docs/dev/04-public-api.md index 2a167ab2d..4849084cc 100644 --- a/docs/dev/04-public-api.md +++ b/docs/dev/04-public-api.md @@ -22,6 +22,14 @@ Equivalent of `karma start`. server.start() ``` +### **server.refreshFiles()** + +Trigger a file list refresh. Returns a promise. + +```javascript +server.refresh() +``` + ### Events The `server` object is an [`EventEmitter`](https://nodejs.org/docs/latest/api/events.html#events_class_events_eventemitter). You can simply listen to events like this: diff --git a/lib/server.js b/lib/server.js index 6edd381bf..0300f3165 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1,6 +1,7 @@ var SocketIO = require('socket.io') var di = require('di') var util = require('util') +var Promise = require('bluebird') var cfg = require('./config') var logger = require('./logger') @@ -98,6 +99,13 @@ Server.prototype.get = function (token) { return this._injector.get(token) } +// Force a refresh of the file list +Server.prototype.refreshFiles = function () { + if (!this._fileList) return Promise.resolve() + + return this._fileList.refresh() +} + // Private Methods // --------------- @@ -105,6 +113,8 @@ Server.prototype._start = function (config, launcher, preprocess, fileList, webS capturedBrowsers, socketServer, executor, done) { var self = this + self._fileList = fileList + config.frameworks.forEach(function (framework) { self._injector.get('framework:' + framework) })