Skip to content

Commit

Permalink
Merge pull request #11 from tago-io/fix/windowsPath
Browse files Browse the repository at this point in the history
Refactor resolveCLIPath function to handle both Windows and Linux paths
  • Loading branch information
vitorfdl authored Jan 26, 2024
2 parents bc2a12d + c3268fa commit 55136a6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lib/config-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ interface IConfigFile {

function resolveCLIPath(suffix: string) {
let path = __dirname;
const pathSlices = path.split("/");
// Handle windows and linux paths
const pathSymbol = path.includes("\\") ? "\\" : "/";

const pathSlices = path.split(pathSymbol);
const cliWordPosition = pathSlices.findIndex((x) => x.includes("cli")) + 1;
path = pathSlices.slice(0, cliWordPosition).join("/");
path = pathSlices.slice(0, cliWordPosition).join(pathSymbol);
return join(path, suffix);
}

Expand Down

0 comments on commit 55136a6

Please sign in to comment.