diff --git a/workspaces/scanner/src/depWalker.ts b/workspaces/scanner/src/depWalker.ts index 630d05f..aa2d294 100644 --- a/workspaces/scanner/src/depWalker.ts +++ b/workspaces/scanner/src/depWalker.ts @@ -232,8 +232,17 @@ export async function depWalker( continue; } - const usedBy: Record = Object.create(null); - for (const [name, version] of [...usedDeps].map((name) => name.split("@"))) { + const usedBy: Record = Object.create(null); + for (const [name, version] of [...usedDeps].map((name) => { + const isScoped = name.startsWith("@"); + if (isScoped) { + const [nameChunk, version] = name.slice(1).split("@"); + + return [`@${nameChunk}`, version]; + } + + return name.split("@") + })) { usedBy[name] = version; } Object.assign(verDescriptor.usedBy, usedBy); diff --git a/workspaces/scanner/test/depWalker.spec.ts b/workspaces/scanner/test/depWalker.spec.ts index b71eb58..0283f09 100644 --- a/workspaces/scanner/test/depWalker.spec.ts +++ b/workspaces/scanner/test/depWalker.spec.ts @@ -92,6 +92,12 @@ test("execute depWalker on @slimio/config", async() => { "@iarna/toml", "@slimio/config" ].sort()); + + const ajvDescriptor = resultAsJSON.ajv.versions["6.12.6"]; + const ajvUsedBy = Object.keys(ajvDescriptor.usedBy); + assert.deepEqual(ajvUsedBy, [ + "@slimio/config" + ]); }); test("execute depWalker on pkg.gitdeps", async() => {