From a767b489a111b5ae719140455ed81acc0cda46ed Mon Sep 17 00:00:00 2001 From: zirkelc Date: Tue, 6 Feb 2024 16:15:57 +0100 Subject: [PATCH] fix: resolve path for warning --- src/getViteConfigPath.test.ts | 4 ++++ src/getViteConfigPath.ts | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/getViteConfigPath.test.ts b/src/getViteConfigPath.test.ts index 5450934..c4ec262 100644 --- a/src/getViteConfigPath.test.ts +++ b/src/getViteConfigPath.test.ts @@ -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`); }); }); diff --git a/src/getViteConfigPath.ts b/src/getViteConfigPath.ts index 44ddc3e..329e368 100644 --- a/src/getViteConfigPath.ts +++ b/src/getViteConfigPath.ts @@ -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}.