Skip to content

Commit

Permalink
fix: resolve path for warning
Browse files Browse the repository at this point in the history
  • Loading branch information
zirkelc committed Feb 6, 2024
1 parent 510805c commit a767b48
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/getViteConfigPath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@ describe("getViteConfigPath", () => {
await expect(
getViteConfigPath(mockWorkingDirectory, "doesNotExist")
).resolves.toBeNull();

expect(core.warning).toHaveBeenCalledOnce();
const warningMessage = vi.mocked(core.warning).mock.calls[0][0];
expect(warningMessage).toContain(`${mockWorkingDirectory}/doesNotExist`);
});
});
10 changes: 5 additions & 5 deletions src/getViteConfigPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ const getViteConfigPath = async (workingDirectory: string, input: string) => {
return await Promise.any(
defaultPaths.map((filePath) => testFilePath(workingDirectory, filePath))
);
}
}

return await testFilePath(workingDirectory, input);
} catch (error) {
const searchPath = input ?
`"${workingDirectory}/${input}"` :
`any default location in "${workingDirectory}"`;
const searchPath = input ?
path.resolve(workingDirectory, input)
: `any default location in "${workingDirectory}"`;

core.warning(stripIndent`
Failed to read vite config file at ${searchPath}.
Expand Down

0 comments on commit a767b48

Please sign in to comment.