create-astro: Add a helpful message for the "could not find commit hash for ..." error (#1984)

* Add a helpful message for the "could not find commit hash for ..." error. This error mostly shows when someone tries to initialize a new project but git is not installed on their system.
This commit is contained in:
Mikkel Tønder 2021-11-23 15:11:56 +01:00 committed by GitHub
parent ef6c34b66b
commit 3e1bdb1a3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'create-astro': patch
---
Add a helpful message for the "could not find commit hash for ..." error

View file

@ -111,6 +111,12 @@ export async function main() {
console.log(yellow("This seems to be a cache related problem. Remove the folder '~/.degit/github/snowpackjs' to fix this error."));
console.log(yellow('For more information check out this issue: https://github.com/snowpackjs/astro/issues/655'));
}
// Helpful message when encountering the "could not find commit hash for ..." error
if (err.code === 'MISSING_REF') {
console.log(yellow("This seems to be an issue with degit. Please check if you have 'git' installed on your system, and install it if you don't have (https://git-scm.com)."));
console.log(yellow("If you do have 'git' installed, please file a new issue here: https://github.com/snowpackjs/astro/issues"));
}
process.exit(1);
}