From 78a7094e0f262c431e904f99cf356be53eee3510 Mon Sep 17 00:00:00 2001
From: Vojta Jina <vojta.jina@gmail.com>
Date: Tue, 25 Jun 2013 19:28:32 -0700
Subject: [PATCH] fix(config): allow parsing the config multiple times

The initial version of the WebStorm plugin did parse the config file multiple times. That was causing errors, because of redefining these global properties.
---
 lib/config.js | 58 +++++++++++++++++++++++++--------------------------
 1 file changed, 29 insertions(+), 29 deletions(-)

diff --git a/lib/config.js b/lib/config.js
index 6b89d7e15..591549c08 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -132,6 +132,35 @@ 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;
@@ -139,35 +168,6 @@ var KarmaDsl = function(config) {
   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];