Skip to content

Commit

Permalink
fix(config): allow parsing the config multiple times
Browse files Browse the repository at this point in the history
The initial version of the WebStorm plugin did parse the config file multiple times. That was causing errors, because of redefining these global properties.
  • Loading branch information
vojtajina committed Jun 26, 2013
1 parent e9a53bd commit 78a7094
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,42 +132,42 @@ var normalizeConfig = function(config, configFilePath) {
return config;
};

// TODO(vojta): remove
var CONST_ERR = '%s is not supported anymore.\n\tPlease use `frameworks = ["%s"];` instead.';
['JASMINE', 'MOCHA', 'QUNIT'].forEach(function(framework) {
[framework, framework + '_ADAPTER'].forEach(function(name) {
Object.defineProperty(global, name, {configurable: true, get: function() {
log.warn(CONST_ERR, name, framework.toLowerCase());
}});
});
});

['REQUIRE', 'REQUIRE_ADAPTER'].forEach(function(name) {
Object.defineProperty(global, name, {configurable: true, get: function() {
log.warn(CONST_ERR, name, 'requirejs');
}});
});

['ANGULAR_SCENARIO', 'ANGULAR_SCENARIO_ADAPTER'].forEach(function(name) {
Object.defineProperty(global, name, {configurable: true, get: function() {
log.warn(CONST_ERR, name, 'ng-scenario');
}});
});

['LOG_DISABLE', 'LOG_INFO', 'LOG_DEBUG', 'LOG_WARN', 'LOG_ERROR'].forEach(function(name) {
Object.defineProperty(global, name, {configurable: true, get: function() {
log.warn('%s is not supported anymore.\n Please use `karma.%s` instead.', name, name);
return constant.LOG_INFO;
}});
});

var KarmaDsl = function(config) {
this.LOG_DISABLE = constant.LOG_DISABLE;
this.LOG_ERROR = constant.LOG_ERROR;
this.LOG_WARN = constant.LOG_WARN;
this.LOG_INFO = constant.LOG_INFO;
this.LOG_DEBUG = constant.LOG_DEBUG;

// TODO(vojta): remove
var CONST_ERR = '%s is not supported anymore.\n\tPlease use `frameworks = ["%s"];` instead.';
['JASMINE', 'MOCHA', 'QUNIT'].forEach(function(framework) {
[framework, framework + '_ADAPTER'].forEach(function(name) {
Object.defineProperty(global, name, {get: function() {
log.warn(CONST_ERR, name, framework.toLowerCase());
}});
});
});

['REQUIRE', 'REQUIRE_ADAPTER'].forEach(function(name) {
Object.defineProperty(global, name, {get: function() {
log.warn(CONST_ERR, name, 'requirejs');
}});
});

['ANGULAR_SCENARIO', 'ANGULAR_SCENARIO_ADAPTER'].forEach(function(name) {
Object.defineProperty(global, name, {get: function() {
log.warn(CONST_ERR, name, 'ng-scenario');
}});
});

['LOG_DISABLE', 'LOG_INFO', 'LOG_DEBUG', 'LOG_WARN', 'LOG_ERROR'].forEach(function(name) {
Object.defineProperty(global, name, {get: function() {
log.warn('%s is not supported anymore.\n Please use `karma.%s` instead.', name, name);
return constant.LOG_INFO;
}});
});

this.configure = function(newConfig) {
Object.keys(newConfig).forEach(function(key) {
config[key] = newConfig[key];
Expand Down

0 comments on commit 78a7094

Please sign in to comment.