Skip to content

Commit

Permalink
refactor(framework): change resolving module path
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Brunner committed May 17, 2016
1 parent 0970c12 commit 1fc3601
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,27 @@ var endsWith = function(substr) {
var _isDuplicate = function(files, file) {
var result = false;
for (var i = 0; i < files.length; i++) {
var pattern = files[i].pattern
var pattern = files[i].pattern;
result = result || endsWith(path.relative(__dirname, file))(pattern);
}
return result;
}
};

var framework = function(files) {
var isDuplicate = _isDuplicate.bind(this, files)
var isDuplicate = _isDuplicate.bind(this, files);

/* Lolex */
var lolexPath = path.resolve(require.resolve('lolex'), '../../lolex.js');
var lolexPath = path.dirname(require.resolve('lolex/packages.json')) + '/lolex.js';

/* Sinon */
var sinonRoot = path.resolve(require.resolve('sinon'), '../../')
var sinonPath = path.resolve(sinonRoot, 'pkg/sinon.js');
var sinonPath = path.dirname(require.resolve('sinon/packages.json')) + '/pkg/sinon.js';
if (!isDuplicate(sinonPath)) {
files.unshift(pattern(lolexPath));
files.unshift(pattern(sinonPath));
}

/* Chai */
var chaiPath = path.resolve(require.resolve('chai'), '../chai.js');
var chaiPath = path.dirname(require.resolve('chai/packages.json')) + '/chai.js';
if (!isDuplicate(chaiPath)) {
files.unshift(pattern(chaiPath));
files.push(pattern(path.join(__dirname, 'chai-adapter.js')));
Expand Down

0 comments on commit 1fc3601

Please sign in to comment.