Skip to content

Commit dbd3154

Browse files
authored
Merge pull request #250 from Eric162/fix-resolve-path
2 parents 642a4e0 + 9b56b27 commit dbd3154

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

packages/ember-css-modules/lib/resolve-path.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,16 @@ function resolveRelativePath(importPath, fromFile, options) {
4444

4545
// Resolve absolute paths pointing to the same app/addon as the importer
4646
function resolveLocalPath(importPath, fromFile, options) {
47-
let appOrAddonDirIndex = fromFile.indexOf(options.ownerName, options.root.length);
47+
const fromFileStartsWithOwnerName = fromFile.substring(options.root.length + 1).startsWith(options.ownerName);
4848

4949
// Depending on the exact version of Ember CLI and/or Embroider in play, the
5050
// app/addon name may or may not be included in `fromFile`'s path. If not, we
5151
// need to strip that prefix from the import path.
52-
if (appOrAddonDirIndex === -1) {
53-
appOrAddonDirIndex = options.root.length;
54-
importPath = ensurePosixPath(importPath).replace(new RegExp('^' + options.ownerName + '/?'), '');
52+
if (!fromFileStartsWithOwnerName) {
53+
importPath = importPath.substring(options.ownerName.length + 1);
5554
}
5655

57-
let prefix = fromFile.substring(0, appOrAddonDirIndex);
58-
let absolutePath = ensurePosixPath(path.resolve(prefix, importPath));
56+
let absolutePath = ensurePosixPath(path.resolve(options.root, importPath));
5957
return internalDep(absolutePath, options);
6058
}
6159

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6621,7 +6621,7 @@ ember-compatibility-helpers@^1.0.2, ember-compatibility-helpers@^1.1.1, ember-co
66216621
semver "^5.4.1"
66226622

66236623
"ember-css-modules@link:packages/ember-css-modules":
6624-
version "1.4.0"
6624+
version "1.5.0"
66256625
dependencies:
66266626
broccoli-bridge "^1.0.0"
66276627
broccoli-concat "^3.2.2"

0 commit comments

Comments
 (0)