Skip to content

Commit 2833d3c

Browse files
feat: migrate from execa to child_process
we need a lot of subtle customization
1 parent 4ff621f commit 2833d3c

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595
"@chakra-ui/react": "2.8.2",
9696
"react-icons": "5.0.1",
9797
"unport": "0.5.0",
98-
"execa": "8.0.1",
9998
"react": "18.2.0",
10099
"react-dom": "18.2.0",
101100
"@vscode/webview-ui-toolkit": "1.4.0",

pnpm-lock.yaml

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/view.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Definition, ParentPort, SgSearch } from './types'
2-
import { execa } from 'execa'
32
import { Unport, ChannelMessage } from 'unport'
43
import * as vscode from 'vscode'
54
import { workspace } from 'vscode'
5+
import { spawn } from 'node:child_process'
66

77
export function activate(context: vscode.ExtensionContext) {
88
const provider = new SearchSidebarProvider(context.extensionUri)
@@ -25,13 +25,20 @@ async function getPatternRes(pattern: string) {
2525
.get('serverPath', 'ast-grep')
2626
const uris = workspace.workspaceFolders?.map(i => i.uri?.fsPath) ?? []
2727

28-
// TODO: use ast-grep lsp to optimize the performance
2928
// TODO: multi-workspaces support
30-
const { stdout } = await execa(
29+
// TODO: the code here is wrong, but we will change it
30+
let stdout = ''
31+
const child = spawn(
3132
command,
32-
['run', '--pattern', pattern, '--json'],
33-
{ cwd: uris[0] }
33+
['run', '--pattern', pattern, '--json=compact'],
34+
{
35+
cwd: uris[0]
36+
}
3437
)
38+
child.stdout.on('data', data => {
39+
stdout += data
40+
})
41+
await new Promise(r => child.on('close', r))
3542

3643
try {
3744
let res: SgSearch[] = JSON.parse(stdout)

0 commit comments

Comments
 (0)