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

Function convertDependencyPath

src/utils/dependencies.ts:10–32  ·  view source on GitHub ↗
(dependencyPath: string, newFilePath: string)

Source from the content-addressed store, hash-verified

8 return "";
9}
10export const convertDependencyPath = (dependencyPath: string, newFilePath: string) => {
11 // Converts ./some/path to ./some.path
12 if (dependencyPath.startsWith("./")) {
13 const trailingPath = removeAfterLastDot(newFilePath.split("routes/")[1].replace(".jsx", "").replace(".tsx", ""));
14 return (
15 "./" +
16 (trailingPath ? trailingPath + "." : "") +
17 dependencyPath.replace("./", "").replace(/__/g, "_").replace(/index/g, "_index").replace(/\//g, ".")
18 );
19 }
20 // We return if it's not a routes folder dependency
21 if (!dependencyPath.includes("routes")) {
22 return dependencyPath;
23 }
24 const parts = dependencyPath.split("routes/");
25 if (parts.length < 2) {
26 return dependencyPath;
27 }
28 // converts some/thing/path => some.thing.path
29 const convertedPath = parts[1].replace(".tsx", "").replace(".jsx", "").replace(/\//g, ".");
30 // returns the path converted eg routes/some/path => routes/some.path
31 return parts[0] + "routes/" + convertedPath;
32};
33
34export const convertRoutePathToTildeFromRelative = (routePath: string, routesFolderNesting: number) => {
35 const parentPath = routePath.match(/\.\.\//g);

Callers 1

updateFileDependenciesFunction · 0.85

Calls 1

removeAfterLastDotFunction · 0.85

Tested by

no test coverage detected