make sure builder.loadConfig does not affect other builders
make sure builder.loadConfig does not affect other builders

in function executeConfigFile() in lib/builder.js there is this code:

        var System = this.loader;

  ....

        new Function(source.toString()).call(global);

The intent, as I understand it, is to have the code in the executed source
to use local System variable from the executeConfigFile scope, instead
of global System variable.

The thing is, it does not work with new Function() - the following test
shows that new Function(...) does not capture variables defined in
the local scope.
(see also http://stackoverflow.com/questions/4599857/are-eval-and-new-function-the-same-thing ).

Below is simplified code extracted from executeConfigFile to show the issue:

it prints

trying with new Function(...)
global System.config called
trying with eval(...)
overriden System.config called
Builder config called

the code:

	global.System = {
	    config: function() {
		console.log('global System.config called');
	    }
	};

	var Builder = {
	    loader: {
		config: function() {
		    console.log('Builder config called');
		}
	    }
	}

	console.log('trying with new Function(...)');
	function executeConfigFile(source) {

	  var System = this.loader;

	  // Save existing System.config function.
	  var systemConfigFunc = System.config;

	  // Assign a new temporary function which filters the config data; see `Builder.prototype.config`.
	  System.config = function(config) {
	      console.log('overriden System.config called');
	    // Invoke existing loader config function.
	    systemConfigFunc(config);
	  };

	  // jshint evil:true
	  new Function(source.toString()).call(global);

	  // Assign back to System.config the original saved function.
	  System.config = systemConfigFunc;
	}

	executeConfigFile.call(Builder, 'System.config();');

	console.log('trying with eval(...)');
	function executeConfigFile_eval(source) {

	  var System = this.loader;

	  // Save existing System.config function.
	  var systemConfigFunc = System.config;

	  // Assign a new temporary function which filters the config data; see `Builder.prototype.config`.
	  System.config = function(config) {
	      console.log('overriden System.config called');
	    // Invoke existing loader config function.
	    systemConfigFunc(config);
	  };

	  // jshint evil:true
	  eval(source.toString());

	  // Assign back to System.config the original saved function.
	  System.config = systemConfigFunc;
	}

	executeConfigFile_eval.call(Builder, 'System.config();');

jrauschenbusch/builder,whitneyit/builder,douglasduteil/builder,lookfirst/builder,systemjs/builder,jrauschenbusch/builder,systemjs/builder,systemjs/builder,alexisvincent/builder,douglasduteil/builder,alexisvincent/builder,alexisvincent/builder,jrauschenbusch/builder,lookfirst/builder,whitneyit/builder