Skip to content

Commit

Permalink
CLI: make getRealPath use dirname if file does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Dec 4, 2024
1 parent d2d0b57 commit 9f38965
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cli/util.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,18 @@ export async function getRealPath(program: Command, p: string) {
);
}
}
return await realpath(path.resolve(process.env.RATOS_BIN_CWD ?? program.getOptionValue('cwd'), p));
try {
return await realpath(path.resolve(process.env.RATOS_BIN_CWD ?? program.getOptionValue('cwd'), p));
} catch (e) {
if (e instanceof Error && 'code' in e && e.code === 'ENOENT' && 'path' in e) {
return (
(await realpath(path.resolve(process.env.RATOS_BIN_CWD ?? program.getOptionValue('cwd'), path.dirname(p)))) +
path.sep +
path.basename(p)
);
}
throw e;
}
}

let alreadyLoaded = false;
Expand Down

0 comments on commit 9f38965

Please sign in to comment.