MetaMask / MetaMask/template-sync
Crashes if `metamask-module-template` already exists in temp directory but is not a Git repo
- Dominant language
- TypeScript
- Stars
- 7
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
I've tried using both `npx @metamask/template-sync` and `yarn dlx @metamask/template-sync` on a project and get the same error:
```
⠋ Fetching module template.Error: Command failed with exit code 128: git pull
fatal: not a git repository (or any of the parent directories): .git
at makeError (/private/var/folders/gz/d8jvtc0n0rncp1xz80k0x62m0000gn/T/xfs-cd883ffe/dlx-65796/node_modules/execa/lib/error.js:60:11)
at handlePromise (/private/var/folders/gz/d8jvtc0n0rncp1xz80k0x62m0000gn/T/xfs-cd883ffe/dlx-65796/node_modules/execa/index.js:118:26)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async task (/private/var/folders/gz/d8jvtc0n0rncp1xz80k0x62m0000gn/T/xfs-cd883ffe/dlx-65796/node_modules/@metamask/template-sync/dist/cli.js:36:21)
at async main (/private/var/folders/gz/d8jvtc0n0rncp1xz80k0x62m0000gn/T/xfs-cd883ffe/dlx-65796/node_modules/@metamask/template-sync/dist/cli.js:114:9) {
shortMessage: 'Command failed with exit code 128: git pull',
command: 'git pull',
escapedCommand: 'git pull',
exitCode: 128,
signal: undefined,
signalDescription: undefined,
stdout: '',
stderr: 'fatal: not a git repository (or any of the parent directories): .git',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
⠼ Fetching module template.
```
It looks like [this line](https://github.com/MetaMask/template-sync/blob/b55310063ffce42ebacf0aafecb22292c2ce8c75/src/cli.ts#L47) is failing. This happens if a `metamask-module-template` directory already exists in the temporary directory root but is not a Git repository for some reason.
(Also, for some reason, the tool doesn't exit, but the spinner next to "Fetching module template" keeps spinning, but that seems like a separate issue.)
It seems like we ought to check that a `.git` directory exists in the `metamask-module-template` directory instead.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/cli.ts at the template-fetching logic around the failing git pull call. Reproduce the case with an existing metamask-module-template directory that lacks .git, then verify that the tool handles that directory appropriately and no longer remains stuck with the fetching spinner.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100