Skip to content

Commit

Permalink
Merge pull request #3973 from ember-cli/config-cache-unc-share
Browse files Browse the repository at this point in the history
Config cache unc share
  • Loading branch information
stefanpenner committed Apr 28, 2015
2 parents d36a41e + 62cab19 commit 487d7ca
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
25 changes: 20 additions & 5 deletions lib/broccoli/broccoli-config-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,27 @@ function ConfigLoader (inputTree, options) {
ConfigLoader.prototype = Object.create(Writer.prototype);
ConfigLoader.prototype.constructor = ConfigLoader;

ConfigLoader.prototype.clearConfigGeneratorCache = function() {
var configPath = this.options.project.configPath() + '.js';
configPath = path.join(this.options.project.root, configPath);
/*
* @private
*
* On windows, when residing on a UNC share (lib or app/addon code), exact
* match here is not possible. Although we could be more precise, there is
* little pain in evicting all fuzzy matches
*
* @method fuzzyPurgeRequireEntry
*/
function fuzzyPurgeRequireEntry(entry) {
var matches = Object.keys(require.cache).filter(function(path) {
return path.indexOf(entry) > -1;
});

matches.forEach(function(entry) {
delete require.cache[entry];
});
}

// clear the previously cached version of this module
delete require.cache[configPath];
ConfigLoader.prototype.clearConfigGeneratorCache = function() {
fuzzyPurgeRequireEntry(this.options.project.configPath() + '.js');
};

ConfigLoader.prototype.updateCache = function(srcDir, destDir) {
Expand Down
1 change: 1 addition & 0 deletions lib/commands/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ module.exports = Command.extend({
},

printPackageBlueprints: function(collection, options) {

var verbose = options.verbose;
var blueprints = collection.blueprints;

Expand Down
8 changes: 4 additions & 4 deletions tests/acceptance/help-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

var path = require('path');
var remove = require('fs-extra').remove;
var tmp = require('tmp-sync');
var expect = require('chai').expect;
var runCommand = require('../helpers/run-command');

var Promise = require('../../lib/ext/promise');
var remove = Promise.denodeify(require('fs-extra').remove);
var root = process.cwd();
var tmproot = path.join(root, 'tmp');
var ember = path.join(root, 'bin', 'ember');
Expand All @@ -19,9 +19,9 @@ describe('Acceptance: ember help', function() {
process.chdir(tmpdir);
});

afterEach(function(done) {
afterEach(function() {
process.chdir(root);
remove(tmproot, done);
return remove(tmproot);
});

it('generate lists blueprints', function() {
Expand Down
6 changes: 5 additions & 1 deletion tests/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@ function addFiles(mocha, files) {
glob.sync(root + files).forEach(mocha.addFile.bind(mocha));
}

addFiles(mocha, '/**/*-test.js');

if (arg === 'all') {
addFiles(mocha, '/**/*-test.js');
addFiles(mocha, '/**/*-slow.js');
} else if (arg) {
mocha.addFile(arg);
} else {
addFiles(mocha, '/**/*-test.js');
}

mocha.run(function(failures) {
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/broccoli/config-loader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ describe('broccoli/broccoli-config-loader', function() {

config.foo = 'blammo';
writeConfig(config);
configLoader.clearConfigGeneratorCache();

configLoader.updateCache(tmpSrcDir, tmpDestDir2);
var updatedConfig = fs.readFileSync(path.join(tmpDestDir2, 'environments', 'development.json'), { encoding: 'utf8' });

expect(originalConfig).to.not.equal(updatedConfig);
expect(originalConfig, 'config/environment.json should have been updated').to.not.equal(updatedConfig);

expect(true, updatedConfig.match(/blammo/));
});
});
Expand Down

0 comments on commit 487d7ca

Please sign in to comment.