Skip to content

Commit

Permalink
Improve error message for third-party template 404s
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Jan 20, 2023
1 parent ad13467 commit bf47c6f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/create-astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,20 @@ export async function main() {
} catch (err: any) {
fs.rmdirSync(cwd);
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 {
console.error(err.message);
}
Expand Down

0 comments on commit bf47c6f

Please sign in to comment.