Skip to content

Commit

Permalink
Merge pull request #75 from benawad/fix/ensure-unique-edges
Browse files Browse the repository at this point in the history
fix/ensure unique edges
  • Loading branch information
sQVe authored Feb 26, 2020
2 parents be9aeb6 + f214fa7 commit a75b68a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index/generateTrees/buildGraph.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import path from "path";

import { findEdges } from "../shared/findEdges";
import { Graph, OldGraph } from "./shared/Graph";
import { findSharedParent } from "./shared/findSharedParent";
Expand All @@ -13,6 +14,7 @@ export function buildGraph(files: string[]) {
const totalFiles: string[] = [];
let numForwardSlashes = 0;
let numBackSlashes = 0;

for (let file of files) {
if (file === ".git") {
continue;
Expand Down
1 change: 1 addition & 0 deletions src/index/generateTrees/buildGraph/addEdge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export function addEdgeToGraph([start, end]: [string, string], graph: Graph) {
if (!(start in graph)) {
graph[start] = [];
}
if (graph[start].includes(end)) return;
graph[start].push(end);
}
27 changes: 27 additions & 0 deletions tests/__snapshots__/end-to-end.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,33 @@ import \\"@testing-library/jest-dom/extend-expect\\";
"
`;
exports[`end-to-end duplicate-imports 1`] = `
"duplicate-imports
├── index
│ ├── routes
│ │ └── home.js
│ └── routes.js
└── index.js"
`;
exports[`end-to-end duplicate-imports: duplicate-imports/index.js 1`] = `
"/* eslint-disable*/
import { five } from \\"./index/routes\\";
import { five } from \\"./index/routes\\";
"
`;
exports[`end-to-end duplicate-imports: duplicate-imports/index/routes.js 1`] = `
"export * from \\"./routes/home\\";
"
`;
exports[`end-to-end duplicate-imports: duplicate-imports/index/routes/home.js 1`] = `
"export const five = 5;
"
`;
exports[`end-to-end duplicates 1`] = `
"duplicates
├── index
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/duplicate-imports/home.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const five = 5;
4 changes: 4 additions & 0 deletions tests/fixtures/duplicate-imports/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* eslint-disable*/

import { five } from "./routes";
import { five } from "./routes";
1 change: 1 addition & 0 deletions tests/fixtures/duplicate-imports/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./home";

0 comments on commit a75b68a

Please sign in to comment.