filing-cabinet
Advanced tools
Comparing version 1.1.0 to 1.2.0
44
index.js
@@ -47,2 +47,7 @@ var path = require('path'); | ||
var result = resolver(partial, filename, directory, config, webpackConfig); | ||
if (result && !path.extname(result)) { | ||
result = result + ext; | ||
} | ||
debug('resolved path for ' + partial + ': ' + result); | ||
@@ -63,28 +68,41 @@ return result; | ||
/** | ||
* @private | ||
* @param {String} partial | ||
* Exposed for testing | ||
* | ||
* @param {String} config | ||
* @param {String} webpackConfig | ||
* @param {String} filename | ||
* @param {String} directory | ||
* @param {String} config | ||
* @return {String} | ||
*/ | ||
function jsLookup(partial, filename, directory, config, webpackConfig) { | ||
var type; | ||
module.exports._getJSType = function(config, webpackConfig, filename) { | ||
if (config) { | ||
type = 'amd'; | ||
return 'amd'; | ||
} | ||
if (webpackConfig) { | ||
type = 'webpack'; | ||
return 'webpack'; | ||
} | ||
if (!type) { | ||
type = getModuleType.sync(filename); | ||
} | ||
return getModuleType.sync(filename); | ||
}; | ||
/** | ||
* @private | ||
* @param {String} partial | ||
* @param {String} filename | ||
* @param {String} directory | ||
* @param {String} config | ||
* @return {String} | ||
*/ | ||
function jsLookup(partial, filename, directory, config, webpackConfig) { | ||
var type = module.exports._getJSType(config, webpackConfig, filename); | ||
switch (type) { | ||
case 'amd': | ||
debug('using amd resolver'); | ||
return amdLookup(config, partial, filename, directory); | ||
return amdLookup({ | ||
config: config, | ||
partial: partial, | ||
filename: filename, | ||
directory: directory | ||
}); | ||
@@ -91,0 +109,0 @@ case 'commonjs': |
{ | ||
"name": "filing-cabinet", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Find files based on partial paths", | ||
@@ -49,3 +49,3 @@ "main": "index.js", | ||
"module-definition": "~2.2.2", | ||
"module-lookup-amd": "~2.0.4", | ||
"module-lookup-amd": "~3.0.0", | ||
"object-assign": "~4.0.1", | ||
@@ -52,0 +52,0 @@ "resolve": "~1.1.7", |
@@ -64,6 +64,5 @@ var assert = require('assert'); | ||
it('assumes amd for es6 modules with a requirejs config', function() { | ||
var stub = sinon.stub(); | ||
var revert = cabinet.__set__('amdLookup', stub); | ||
var spy = sinon.spy(cabinet, '_getJSType'); | ||
cabinet({ | ||
var result = cabinet({ | ||
partial: './bar', | ||
@@ -73,9 +72,9 @@ filename: 'js/es6/foo.js', | ||
config: { | ||
baseUrl: 'js/' | ||
baseUrl: './' | ||
} | ||
}); | ||
assert.ok(stub.called); | ||
revert(); | ||
assert.ok(spy.called); | ||
assert.equal(result, 'js/es6/bar.js'); | ||
spy.restore(); | ||
}); | ||
@@ -124,3 +123,3 @@ }); | ||
assert.equal(result.length, 0); | ||
assert.equal(result, ''); | ||
}); | ||
@@ -240,3 +239,3 @@ | ||
assert.ok(stub.called); | ||
assert.equal(path, 'foo'); | ||
assert.equal(path, 'foo.foobar'); | ||
}); | ||
@@ -243,0 +242,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16556
421
+ Addedmodule-lookup-amd@3.0.0(transitive)
- Removedmodule-lookup-amd@2.0.5(transitive)
Updatedmodule-lookup-amd@~3.0.0