MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / calculatePathDifference

Function calculatePathDifference

src/utils/dependencies.ts:60–71  ·  view source on GitHub ↗
(rootFolder: string, nestedFolder: string)

Source from the content-addressed store, hash-verified

58 * @returns Returns the number of levels between the two
59 */
60export const calculatePathDifference = (rootFolder: string, nestedFolder: string) => {
61 const rootParts = rootFolder.split("/");
62 const nestedParts = nestedFolder.split("/");
63
64 let i = 0;
65 while (i < rootParts.length && i < nestedParts.length && rootParts[i] === nestedParts[i]) {
66 i++;
67 }
68
69 const pathDifference = nestedParts.length - i;
70 return pathDifference;
71};
72/**
73 * Returns the difference in two paths as a string
74 * @example "routes/something" and "routes/something/nested/path" would return "nested/path"

Callers 1

updateFileDependenciesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected