Skip to content

Commit

Permalink
feat(server): Add public api to force a file list refresh.
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Jul 17, 2015
1 parent 35a0dcf commit b3c462a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/dev/04-public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -98,13 +99,22 @@ 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
// ---------------

Server.prototype._start = function (config, launcher, preprocess, fileList, webServer,
capturedBrowsers, socketServer, executor, done) {
var self = this

self._fileList = fileList

config.frameworks.forEach(function (framework) {
self._injector.get('framework:' + framework)
})
Expand Down

0 comments on commit b3c462a

Please sign in to comment.