Skip to content

Commit

Permalink
fix: Resolve path for warning (#337)
Browse files Browse the repository at this point in the history
* fix: resolve path for warning

* format
  • Loading branch information
zirkelc committed Feb 6, 2024
1 parent 510805c commit 4ac2eb9
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
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
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 4ac2eb9

Please sign in to comment.