Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wrangler init should not crash if Git is not available on Windows #1033

Merged
merged 1 commit into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .changeset/metal-bees-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
"wrangler": patch
---

fix: `wrangler init` should not crash if Git is not available on Windows

We check for the presence of Git by trying to run `git --version`.
On non-Windows we get an Error with `code` set to "ENOENT".
One Windows we get a different error:

```
{
"shortMessage":"Command failed with exit code 1: git --version",
"command":"git --version",
"escapedCommand":"git --version",
"exitCode":1,
"stdout":"",
"stderr":"'git' is not recognized as an internal or external command,\r\noperable program or batch file.",
"failed":true,
"timedOut":false,
"isCanceled":false,
"killed":false
}
```

Since we don't really care what the error is, now we just assume that Git
is not available if an error is thrown.

Fixes #1022
7 changes: 1 addition & 6 deletions packages/wrangler/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,7 @@ export async function main(argv: string[]): Promise<void> {
try {
isGitInstalled = (await execa("git", ["--version"])).exitCode === 0;
} catch (err) {
if ((err as { code: string | undefined }).code !== "ENOENT") {
// only throw if the error is not because git is not installed
throw err;
} else {
isGitInstalled = false;
}
isGitInstalled = false;
}
if (!isInsideGitProject && isGitInstalled) {
const shouldInitGit =
Expand Down