@@ -3,6 +3,8 @@ import path from 'path'
33import fs from 'fs'
44import { Result , err , ok } from '@bus/result'
55import { traceVerbose , traceInfo } from './common/log'
6+ import { parse } from 'shell-quote'
7+ import { z } from 'zod'
68
79export interface SqlmeshConfiguration {
810 projectPath : string
@@ -24,6 +26,8 @@ function getSqlmeshConfiguration(): SqlmeshConfiguration {
2426 }
2527}
2628
29+ const stringsArray = z . array ( z . string ( ) )
30+
2731/**
2832 * Get the SQLMesh LSP entry point from VS Code settings. undefined if not set
2933 * it's expected to be a string in the format "command arg1 arg2 ...".
@@ -39,12 +43,16 @@ export function getSqlmeshLspEntryPoint():
3943 return undefined
4044 }
4145 // Split the entry point into command and arguments
42- const parts = config . lspEntryPoint . split ( ' ' )
43- const entrypoint = parts [ 0 ]
44- const args = parts . slice ( 1 )
45- if ( args . length === 0 ) {
46- return { entrypoint, args : [ ] }
46+ const parts = parse ( config . lspEntryPoint )
47+ const parsed = stringsArray . safeParse ( parts )
48+ if ( ! parsed . success ) {
49+ throw new Error (
50+ `Invalid lspEntrypoint configuration: ${ config . lspEntryPoint } . Expected a
51+ string in the format "command arg1 arg2 ...".` ,
52+ )
4753 }
54+ const entrypoint = parsed . data [ 0 ]
55+ const args = parsed . data . slice ( 1 )
4856 return { entrypoint, args }
4957}
5058
0 commit comments