Skip to content

Commit

Permalink
fix(commands): handle nonexistent settings file case in welcome()
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Jul 20, 2023
1 parent 3754997 commit 00d359e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/commands/welcome.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { existsSync } from 'fs'
import { join } from 'path'
import { Position, Range, ViewColumn, WorkspaceEdit, window, workspace } from 'vscode'
import { Position, Range, Uri, ViewColumn, WorkspaceEdit, window, workspace } from 'vscode'

import { DocumentationPath } from '../constants'
import { handleMessageItems } from '../helpers/handleMessageItems'
Expand All @@ -26,6 +27,9 @@ export async function welcome() {
await showDocumentation(DocumentationPath.WELCOME)

const workspaceSettingsPath = join(getUserWorkspaceRootPath(), '.vscode', 'settings.json')
if (!existsSync(workspaceSettingsPath)) {
await workspace.fs.writeFile(Uri.file(workspaceSettingsPath), Buffer.from('{}'))
}
const workspaceSettingsDocument = await workspace.openTextDocument(workspaceSettingsPath)
const workspaceSettingsText = workspaceSettingsDocument.getText()

Expand Down

0 comments on commit 00d359e

Please sign in to comment.