Skip to content

Commit

Permalink
Fixed controllerPath on addControllerToModule
Browse files Browse the repository at this point in the history
  • Loading branch information
eryk-vieira committed Aug 2, 2023
1 parent 0159fc6 commit 54f9a9f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/generate/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,18 +156,18 @@ export const createTemplate = async ({
}
}

let controllerPath = "";
let controllerPath = "./";
const pathCount = (path.split("/")).length;

if (path === "") {
controllerPath = `${file.slice(0, file.lastIndexOf('.'))}`;
controllerPath += `${file.slice(0, file.lastIndexOf('.'))}`;
} else if (pathCount === 1) {
controllerPath = `${path}/${file.slice(0, file.lastIndexOf('.'))}`;
controllerPath += `${path}/${file.slice(0, file.lastIndexOf('.'))}`;
} else if (pathCount === 2) {
controllerPath = `${path.split("/")[1]}/${file.slice(0, file.lastIndexOf('.'))}`;
controllerPath += `${path.split("/")[1]}/${file.slice(0, file.lastIndexOf('.'))}`;
} else {
const segments: string[] = path.split("/");
controllerPath = `${segments[segments.length-1]}/${file.slice(0, file.lastIndexOf('.'))}`;
controllerPath += `${segments[segments.length-1]}/${file.slice(0, file.lastIndexOf('.'))}`;
}

if (moduleExist) {
Expand Down

0 comments on commit 54f9a9f

Please sign in to comment.