Skip to content

Commit

Permalink
Open settings if wollok-ts-cli path is missing (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino authored Oct 6, 2023
1 parent 5f9e321 commit f84488a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
fsToShell,
unknownToShell,
} from './platform-string-utils'
import { wollokLSPExtensionCode } from './constants'

export const subscribeWollokCommands = (context: ExtensionContext): void => {
context.subscriptions.push(registerCLICommand('wollok.start.repl', startRepl))
Expand Down Expand Up @@ -60,7 +61,7 @@ const DYNAMIC_DIAGRAM_URI = 'http://localhost:3000/'

export const startRepl = (): Task => {
const currentDocument = window.activeTextEditor?.document
const wollokLSPConfiguration = workspace.getConfiguration('wollokLSP')
const wollokLSPConfiguration = workspace.getConfiguration(wollokLSPExtensionCode)
const dynamicDiagramDarkMode = wollokLSPConfiguration.get('dynamicDiagramDarkMode') ?? false
const cliCommands = [`repl`, ...getFiles(currentDocument), '--skipValidations', dynamicDiagramDarkMode ? '--darkMode' : '']
// Terminate previous tasks
Expand Down Expand Up @@ -94,9 +95,12 @@ const registerCLICommand = (
)

const wollokCLITask = (task: string, name: string, cliCommands: string[]) => {
const wollokCliPath: string = workspace.getConfiguration('wollokLSP').get('cli-path')
const wollokCliPath: string = workspace.getConfiguration(wollokLSPExtensionCode).get('cli-path')
// TODO: i18n - but it's in the server
if (!wollokCliPath) throw new Error('Missing configuration WollokLSP/cli-path in order to run Wollok tasks')
if (!wollokCliPath) {
vscode.commands.executeCommand('workbench.action.openSettings', wollokLSPExtensionCode)
throw new Error('Missing configuration WollokLSP/cli-path. Set the path where wollok-ts-cli is located in order to run Wollok tasks')
}
const wollokCli = unknownToShell(wollokCliPath)
const folder = workspace.workspaceFolders[0]
const shellCommand = [
Expand Down
1 change: 1 addition & 0 deletions client/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const wollokLSPExtensionCode = 'wollokLSP'

0 comments on commit f84488a

Please sign in to comment.