Skip to content

Commit

Permalink
fix(build-resources): allow local paths in module build resources
Browse files Browse the repository at this point in the history
  • Loading branch information
niieani committed Jun 22, 2016
1 parent f67ba69 commit b206d2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/build-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,14 @@ function getResourcesOfPackage(resources = {}, packagePath = undefined, relative
let fromPaths = Array.isArray(resource.path) ? resource.path : [resource.path];
for (let fromPath of fromPaths) {
debug(`<${externalModule || path.basename(packagePath)}> [resolving] '${fromPath}'`);
if (externalModule && fromPath.indexOf('.') !== 0)
fromPath = fixRelativeFromPath(fromPath, undefined, undefined, externalModule);

if (externalModule) {
if (fromPath.indexOf('.') !== 0) // origin unsure, could be external //
fromPath = fixRelativeFromPath(fromPath, undefined, undefined, externalModule);
else // we know it will be local from within the module
fromPath = path.join(externalModule, fromPath);
}

processFromPath(resources, fromPath, resource, packagePath, relativeToDir, overrideBlock);
}
}
Expand Down
6 changes: 4 additions & 2 deletions test/build-resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var filesExpectedToLoad = [
'node_modules/external-3/dist/commonjs/sub/resource-4.js',
'node_modules/external-3/dist/commonjs/sub/resource-5.html',
'node_modules/external-3/dist/commonjs/sub/resource-6.js',
'aurelia-framework',
'node_modules/aurelia-templating-resources/dist/commonjs/compose.js',
'node_modules/aurelia-templating-resources/dist/commonjs/compose.html',
'node_modules/aurelia-templating-resources/dist/commonjs/compose.js',
Expand Down Expand Up @@ -87,6 +88,7 @@ var expectedRequireStrings = [
'external-3/sub/resource-4.js',
'external-3/sub/resource-5.html',
'external-3/dist/commonjs/sub/resource-6.js',
'aurelia-framework',
'aurelia-templating-resources/compose',
'aurelia-templating-resources/compose.html',
'aurelia-templating-resources/compose.js',
Expand Down Expand Up @@ -126,8 +128,8 @@ describe('Dependency resolution', function () {
filesLoaded.push(resolved[key].source.replace(__dirname + path.sep, ''));
}

// console.log(requireStrings)
// console.log(filesLoaded)
console.log(requireStrings)
console.log(filesLoaded)

assert.sameMembers(requireStrings, expectedRequireStrings);
assert.sameMembers(filesLoaded, filesExpectedToLoad);
Expand Down

0 comments on commit b206d2e

Please sign in to comment.