Skip to content

Commit

Permalink
refactor(config): access definition of customs from basis
Browse files Browse the repository at this point in the history
Allows custom(reporter|launcher)'a args to be accessible from
Launcher(Reporter)Base

Closes karma-runner#1738
  • Loading branch information
comdiv committed Dec 2, 2015
1 parent 8f61eb2 commit a927e5e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/config.js
Expand Up @@ -195,7 +195,14 @@ var normalizeConfig = function (config, configFilePath) {
}

module[type + ':' + name] = ['factory', function (injector) {
return injector.createChild([locals], [token]).get(token)
var result = injector.createChild([locals], [token]).get(token)
// we cannot force external launchers to keep args somewhere
// and use it in creation, but we require to keep args for base
// classes/decorators usage
// while it stores in locals - it will be not simple DI way
// to access when launcher will be created, so setup it explicitly
result.$definition = result.$definition || definition
return result
}]
hasSomeInlinedPlugin = true
})
Expand Down
5 changes: 5 additions & 0 deletions lib/launchers/base.js
Expand Up @@ -99,6 +99,11 @@ var BaseLauncher = function (id, emitter) {
return this.name
}

this.getDefinition = function () {
this.$definition = this.$definition || {}
return this.$definition
}

this._done = function (error) {
killingPromise = killingPromise || Promise.resolve()

Expand Down
5 changes: 5 additions & 0 deletions lib/reporters/base.js
Expand Up @@ -71,6 +71,11 @@ var BaseReporter = function (formatError, reportSlow, adapter) {
}
}

this.getDefinition = function () {
this.$definition = this.$definition || {}
return this.$definition
}

this.onSpecComplete = function (browser, result) {
if (result.skipped) {
this.specSkipped(browser, result)
Expand Down

0 comments on commit a927e5e

Please sign in to comment.