Skip to content

Commit

Permalink
fix: error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
yrming committed Dec 31, 2023
1 parent 53a64c5 commit 6c1e90e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"publisher": "YRM",
"name": "starter-templates",
"displayName": "Starter Templates",
"version": "0.6.0",
"version": "0.6.1",
"description": "Kickstart your project with a Starter Template in VSCode",
"license": "MIT",
"repository": {
Expand Down
15 changes: 10 additions & 5 deletions src/commands/starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class StarterCommands extends BaseCommands {
if (!triggerData)
return

await window.withProgress({
const code = await window.withProgress({
location: ProgressLocation.Notification,
}, async (progress) => {
progress.report({
Expand Down Expand Up @@ -72,14 +72,19 @@ export class StarterCommands extends BaseCommands {
default:
break
}

if (templateId !== 'create-next-app')
await this.handleCommonActions(projectPath!)

return 0
}
catch (error) {
window.showErrorMessage('Failed to create prpject!')
return -1
}

if (templateId !== 'create-next-app')
await this.handleCommonActions(projectPath!)
})

return code
}

private async handleCommonActions(projectPath: string) {
Expand All @@ -104,7 +109,7 @@ export class StarterCommands extends BaseCommands {
})
}
catch (error) {
window.showErrorMessage('Failed to install dependencies!')
window.showWarningMessage('Failed to install dependencies!')
}
})
}
Expand Down
5 changes: 3 additions & 2 deletions src/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ async function handleStarterCreateTrigger(wf: WorkspaceFolder): Promise<void> {

try {
markProjectCreationStarted()
await createStarterProject(fsPath(wf.uri), json)
handleStarterWelcome(wf, json)
const success = await createStarterProject(fsPath(wf.uri), json)
if (success)
handleStarterWelcome(wf, json)
}
finally {
markProjectCreationEnded()
Expand Down

0 comments on commit 6c1e90e

Please sign in to comment.