Improve error message for third-party template 404s (#5920)
This commit is contained in:
parent
ad13467a84
commit
f27bb3d79f
2 changed files with 19 additions and 1 deletions
5
.changeset/large-hotels-give.md
Normal file
5
.changeset/large-hotels-give.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'create-astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve error message for third-party template 404s
|
|
@ -192,7 +192,20 @@ export async function main() {
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
fs.rmdirSync(cwd);
|
fs.rmdirSync(cwd);
|
||||||
if (err.message.includes('404')) {
|
if (err.message.includes('404')) {
|
||||||
console.error(`Template ${color.underline(options.template)} does not exist!`);
|
console.error(`Could not find template ${color.underline(options.template)}!`);
|
||||||
|
if (isThirdParty) {
|
||||||
|
const hasBranch = options.template.includes('#');
|
||||||
|
if (hasBranch) {
|
||||||
|
console.error('Are you sure this GitHub repo and branch exist?');
|
||||||
|
} else {
|
||||||
|
console.error(
|
||||||
|
`Are you sure this GitHub repo exists?` +
|
||||||
|
`This command uses the ${color.bold('main')} branch by default.\n` +
|
||||||
|
`If the repo doesn't have a main branch, specify a custom branch name:\n` +
|
||||||
|
color.underline(options.template + color.bold('#branch-name'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error(err.message);
|
console.error(err.message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue