Skip to content

Commit cfa97fa

Browse files
Fix scoped addon names (#412)
This fixes a bug where addons with `@foo/bar` style names would break coverage generation. It also adds in tests for v1 addons and scoped v1 addons.
1 parent 1f50606 commit cfa97fa

File tree

85 files changed

+13176
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+13176
-123
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"release-it": "^16.2.1",
2121
"rimraf": "^5.0.5",
2222
"vite": "^4.5.0",
23-
"vitest": "^1.0.0-beta.4"
23+
"vitest": "^1.4.0"
2424
},
2525
"engines": {
2626
"node": ">= 18",

packages/ember-cli-code-coverage/lib/attach-middleware.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function adjustCoverageKey(
101101
let gjsGtsRegex = /\.g[tj]s$/gm;
102102

103103
let relativePath = path.relative(root, filepath);
104-
105104
// we can determine if file is coming from embroider based on how the path looks
106105
if (embroiderTmpPathRegex.test(filepath)) {
107106
relativePath = normalizeRelativePath(root, filepath);
@@ -115,8 +114,16 @@ function adjustCoverageKey(
115114
relativePath = normalizePathForTemplateImports(relativePath);
116115
}
117116

118-
let namespace = relativePath.split(path.sep)[0];
119-
let pathWithoutNamespace = relativePath.split(path.sep).slice(1);
117+
let namespace, pathWithoutNamespace;
118+
119+
if (relativePath.startsWith('@')) {
120+
namespace = relativePath.split(path.sep).slice(0, 2).join('/');
121+
pathWithoutNamespace = relativePath.split(path.sep).slice(2);
122+
} else {
123+
namespace = relativePath.split(path.sep)[0];
124+
pathWithoutNamespace = relativePath.split(path.sep).slice(1);
125+
}
126+
120127
let namespaceKey = namespace;
121128

122129
if (pathWithoutNamespace[0] === 'test-support') {

0 commit comments

Comments
 (0)