Skip to content

Commit b2779b0

Browse files
committed
Remove leading slash from root manifests
This causes issues with GitHub dependency Graph
1 parent 64db6d9 commit b2779b0

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

componentDetection.test.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ describe("ComponentDetection.processComponentsToManifests", () => {
8686
},
8787
isDevelopmentDependency: false,
8888
topLevelReferrers: [], // Empty = direct dependency
89-
locationsFoundAt: ["/package.json"]
89+
locationsFoundAt: ["package.json"]
9090
}
9191
];
9292

9393
const dependencyGraphs: DependencyGraphs = {
94-
"/package.json": {
94+
"package.json": {
9595
graph: { "test-package": null },
9696
explicitlyReferencedComponentIds: ["test-package 1.0.0 - npm"],
9797
developmentDependencies: [],
@@ -102,7 +102,7 @@ describe("ComponentDetection.processComponentsToManifests", () => {
102102
const manifests = ComponentDetection.processComponentsToManifests(componentsFound, dependencyGraphs);
103103

104104
expect(manifests).toHaveLength(1);
105-
expect(manifests[0].name).toBe("/package.json");
105+
expect(manifests[0].name).toBe("package.json");
106106
expect(manifests[0].directDependencies()).toHaveLength(1);
107107
expect(manifests[0].indirectDependencies()).toHaveLength(0);
108108
expect(manifests[0].countDependencies()).toBe(1);
@@ -135,12 +135,12 @@ describe("ComponentDetection.processComponentsToManifests", () => {
135135
}
136136
}
137137
],
138-
locationsFoundAt: ["/package.json"]
138+
locationsFoundAt: ["package.json"]
139139
}
140140
];
141141

142142
const dependencyGraphs: DependencyGraphs = {
143-
"/package.json": {
143+
"package.json": {
144144
graph: { "parent-package": null },
145145
explicitlyReferencedComponentIds: [],
146146
developmentDependencies: [],
@@ -151,7 +151,7 @@ describe("ComponentDetection.processComponentsToManifests", () => {
151151
const manifests = ComponentDetection.processComponentsToManifests(componentsFound, dependencyGraphs);
152152

153153
expect(manifests).toHaveLength(1);
154-
expect(manifests[0].name).toBe("/package.json");
154+
expect(manifests[0].name).toBe("package.json");
155155
expect(manifests[0].directDependencies()).toHaveLength(0);
156156
expect(manifests[0].indirectDependencies()).toHaveLength(1);
157157
expect(manifests[0].countDependencies()).toBe(1);
@@ -184,10 +184,11 @@ describe('normalizeDependencyGraphPaths', () => {
184184
const normalized = ComponentDetection.normalizeDependencyGraphPaths(dependencyGraphs, filePathInput);
185185
// Restore process.cwd
186186
(process as any).cwd = originalCwd;
187-
expect(Object.keys(normalized)).toContain('/a/package.json');
188-
expect(Object.keys(normalized)).toContain('/b/package.json');
189-
expect(normalized['/a/package.json'].graph).toEqual({ 'foo': null });
190-
expect(normalized['/b/package.json'].graph).toEqual({ 'bar': null });
187+
expect(Object.keys(normalized)).toContain('a/package.json');
188+
expect(Object.keys(normalized)).toContain('b/package.json');
189+
expect(normalized['a/package.json'].graph).toEqual({ 'foo': null });
190+
expect(normalized['b/package.json'].graph).toEqual({ 'bar': null });
191+
console.log(normalized)
191192
});
192193
});
193194

componentDetection.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,6 @@ export default class ComponentDetection {
283283
for (const absPath in dependencyGraphs) {
284284
// Make the path relative to the baseDir
285285
let relPath = path.relative(baseDir, absPath).replace(/\\/g, '/');
286-
// Ensure leading slash to represent repo root
287-
if (!relPath.startsWith('/')) relPath = '/' + relPath;
288286
normalized[relPath] = dependencyGraphs[absPath];
289287
}
290288
return normalized;

0 commit comments

Comments
 (0)