Skip to content

Commit eca0cce

Browse files
committed
addressing comments
1 parent 64e9774 commit eca0cce

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

pnpm-lock.yaml

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vscode/extension/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@
141141
"dependencies": {
142142
"@duckdb/node-api": "1.3.2-alpha.25",
143143
"@types/fs-extra": "^11.0.4",
144+
"@types/shell-quote": "^1.7.5",
144145
"@vscode/python-extension": "^1.0.5",
145146
"fs-extra": "^11.3.0",
147+
"shell-quote": "^1.8.3",
146148
"vscode-jsonrpc": "^8.2.1",
147149
"vscode-languageclient": "^9.0.1",
148150
"zod": "^3.25.76"

vscode/extension/src/utilities/config.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import path from 'path'
33
import fs from 'fs'
44
import { Result, err, ok } from '@bus/result'
55
import { traceVerbose, traceInfo } from './common/log'
6+
import { parse } from 'shell-quote'
7+
import { z } from 'zod'
68

79
export 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

vscode/extension/tests/configuration.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ${sqlmeshLSPFile} "$@"`,
6666
}
6767

6868
test.describe('Test LSP Entrypoint configuration', () => {
69-
test('specify single entrypoint relalative path', async ({
69+
test('specify single entrypoint relative path', async ({
7070
page,
7171
sharedCodeServer,
7272
tempDir,

0 commit comments

Comments
 (0)