Skip to content
This repository has been archived by the owner on Aug 13, 2024. It is now read-only.

Commit

Permalink
fixed jspm imports in sass files for most environments (i.e. cordova)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Kehr committed Jun 9, 2016
1 parent c377c97 commit 43abb50
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/resolve-path.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ async function resolvePath(request) {
current = current.replace(/^jspm:/, '');
if (!current.match(/\.s(c|a)ss/)) current += '.scss';
// we need the parent, if the module of the file is not a primary install
let parent = `${System.baseURL}${request.options.urlBase}`;
// when adding urls, some unwanted double slashes may occur
if (System.baseURL.slice(-1) === '/' && request.options.urlBase.slice(0, 1) === '/') {
parent = `${System.baseURL}${request.options.urlBase.slice(1)}`;
}
const parentURL = url.parse(System.baseURL);
parentURL.pathname = request.options.urlBase;
const parent = url.format(parentURL);
const file = await System.normalize(current, parent);
return file.replace(/\.js$|\.ts$/, '');
}
Expand Down
2 changes: 1 addition & 1 deletion test/resolve-path-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('resolve-path', () => {
const request = {
current: 'jspm:indirect-package/mock-asset',
previous: 'stdin',
options: { urlBase: '/jspm_packages/npm/mock-package@1.0.0/' },
options: { urlBase: url.parse(`${__dirname}/jspm_packages/npm/mock-package@1.0.0/`).path },
};
const p = await resolvePath(request, '/');
// System.normalize in resolvePath will give us the absolute path
Expand Down

0 comments on commit 43abb50

Please sign in to comment.