From 7dce5819d1d257d69262a9b999e74487239cee49 Mon Sep 17 00:00:00 2001 From: LorisSigrist Date: Mon, 25 Mar 2024 16:00:09 +0100 Subject: [PATCH] Fix how `openRepository` is used in unplugin-plugin & paraglide init --- .changeset/mighty-brooms-leave.md | 6 ++++++ .../paraglide/paraglide-js-adapter-unplugin/src/index.ts | 2 +- .../paraglide/paraglide-js/src/cli/commands/init.ts | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/mighty-brooms-leave.md diff --git a/.changeset/mighty-brooms-leave.md b/.changeset/mighty-brooms-leave.md new file mode 100644 index 0000000000..2bf55b745b --- /dev/null +++ b/.changeset/mighty-brooms-leave.md @@ -0,0 +1,6 @@ +--- +"@inlang/paraglide-js-adapter-unplugin": patch +"@inlang/paraglide-js": patch +--- + +fix `openRepository` crash in non-git environments diff --git a/inlang/source-code/paraglide/paraglide-js-adapter-unplugin/src/index.ts b/inlang/source-code/paraglide/paraglide-js-adapter-unplugin/src/index.ts index 4ca1cba8c3..e576933b84 100644 --- a/inlang/source-code/paraglide/paraglide-js-adapter-unplugin/src/index.ts +++ b/inlang/source-code/paraglide/paraglide-js-adapter-unplugin/src/index.ts @@ -64,7 +64,7 @@ export const paraglide = createUnplugin((config: UserConfig) => { const repoRoot = await findRepoRoot({ nodeishFs: fs, path: projectPath }) - const repo = await openRepository(repoRoot || process.cwd(), { + const repo = await openRepository(repoRoot || "file://" + process.cwd(), { nodeishFs: fs, }) diff --git a/inlang/source-code/paraglide/paraglide-js/src/cli/commands/init.ts b/inlang/source-code/paraglide/paraglide-js/src/cli/commands/init.ts index 35b557da1c..20f9655bbc 100644 --- a/inlang/source-code/paraglide/paraglide-js/src/cli/commands/init.ts +++ b/inlang/source-code/paraglide/paraglide-js/src/cli/commands/init.ts @@ -44,7 +44,7 @@ export const initCommand = new Command() // We are risking that there is no git repo. As long as we only use FS features and no Git features // from the SDK we should be fine. // Basic operations like `loadProject` should always work without a repo since it's used in CI. - const repo = await openRepository(repoRoot ?? process.cwd(), { + const repo = await openRepository(repoRoot ?? "file://" + process.cwd(), { nodeishFs: nodeFsPromises, })