Skip to content

Commit 832ffd2

Browse files
authored
fix: Use process.stdout.write instead of console.log (#3508)
1 parent b261430 commit 832ffd2

File tree

5 files changed

+15
-12
lines changed

5 files changed

+15
-12
lines changed

packages/opencode/src/cli/cmd/debug/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { EOL } from "os"
12
import { Config } from "../../../config/config"
23
import { bootstrap } from "../../bootstrap"
34
import { cmd } from "../cmd"
@@ -8,7 +9,7 @@ export const ConfigCommand = cmd({
89
async handler() {
910
await bootstrap(process.cwd(), async () => {
1011
const config = await Config.get()
11-
console.log(JSON.stringify(config, null, 2))
12+
process.stdout.write(JSON.stringify(config, null, 2) + EOL)
1213
})
1314
},
1415
})

packages/opencode/src/cli/cmd/debug/file.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const FileSearchCommand = cmd({
1414
async handler(args) {
1515
await bootstrap(process.cwd(), async () => {
1616
const results = await File.search({ query: args.query })
17-
console.log(results.join(EOL))
17+
process.stdout.write(results.join(EOL) + EOL)
1818
})
1919
},
2020
})
@@ -30,7 +30,7 @@ const FileReadCommand = cmd({
3030
async handler(args) {
3131
await bootstrap(process.cwd(), async () => {
3232
const content = await File.read(args.path)
33-
console.log(content)
33+
process.stdout.write(JSON.stringify(content, null, 2) + EOL)
3434
})
3535
},
3636
})
@@ -41,7 +41,7 @@ const FileStatusCommand = cmd({
4141
async handler() {
4242
await bootstrap(process.cwd(), async () => {
4343
const status = await File.status()
44-
console.log(JSON.stringify(status, null, 2))
44+
process.stdout.write(JSON.stringify(status, null, 2) + EOL)
4545
})
4646
},
4747
})
@@ -57,7 +57,7 @@ const FileListCommand = cmd({
5757
async handler(args) {
5858
await bootstrap(process.cwd(), async () => {
5959
const files = await File.list(args.path)
60-
console.log(JSON.stringify(files, null, 2))
60+
process.stdout.write(JSON.stringify(files, null, 2) + EOL)
6161
})
6262
},
6363
})

packages/opencode/src/cli/cmd/debug/lsp.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { LSP } from "../../../lsp"
22
import { bootstrap } from "../../bootstrap"
33
import { cmd } from "../cmd"
44
import { Log } from "../../../util/log"
5+
import { EOL } from "os"
56

67
export const LSPCommand = cmd({
78
command: "lsp",
@@ -16,7 +17,7 @@ const DiagnosticsCommand = cmd({
1617
async handler(args) {
1718
await bootstrap(process.cwd(), async () => {
1819
await LSP.touchFile(args.file, true)
19-
console.log(JSON.stringify(await LSP.diagnostics(), null, 2))
20+
process.stdout.write(JSON.stringify(await LSP.diagnostics(), null, 2) + EOL)
2021
})
2122
},
2223
})
@@ -28,7 +29,7 @@ export const SymbolsCommand = cmd({
2829
await bootstrap(process.cwd(), async () => {
2930
using _ = Log.Default.time("symbols")
3031
const results = await LSP.workspaceSymbol(args.query)
31-
console.log(JSON.stringify(results, null, 2))
32+
process.stdout.write(JSON.stringify(results, null, 2) + EOL)
3233
})
3334
},
3435
})
@@ -40,7 +41,7 @@ export const DocumentSymbolsCommand = cmd({
4041
await bootstrap(process.cwd(), async () => {
4142
using _ = Log.Default.time("document-symbols")
4243
const results = await LSP.documentSymbol(args.uri)
43-
console.log(JSON.stringify(results, null, 2))
44+
process.stdout.write(JSON.stringify(results, null, 2) + EOL)
4445
})
4546
},
4647
})

packages/opencode/src/cli/cmd/debug/ripgrep.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const TreeCommand = cmd({
1818
}),
1919
async handler(args) {
2020
await bootstrap(process.cwd(), async () => {
21-
console.log(await Ripgrep.tree({ cwd: Instance.directory, limit: args.limit }))
21+
process.stdout.write(await Ripgrep.tree({ cwd: Instance.directory, limit: args.limit }) + EOL)
2222
})
2323
},
2424
})
@@ -49,7 +49,7 @@ const FilesCommand = cmd({
4949
files.push(file)
5050
if (args.limit && files.length >= args.limit) break
5151
}
52-
console.log(files.join(EOL))
52+
process.stdout.write(files.join(EOL) + EOL)
5353
})
5454
},
5555
})
@@ -78,6 +78,6 @@ const SearchCommand = cmd({
7878
glob: args.glob as string[] | undefined,
7979
limit: args.limit,
8080
})
81-
console.log(JSON.stringify(results, null, 2))
81+
process.stdout.write(JSON.stringify(results, null, 2) + EOL)
8282
},
8383
})

packages/opencode/src/cli/cmd/debug/scrap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { EOL } from "os"
12
import { Project } from "../../../project/project"
23
import { Log } from "../../../util/log"
34
import { cmd } from "../cmd"
@@ -8,7 +9,7 @@ export const ScrapCommand = cmd({
89
async handler() {
910
const timer = Log.Default.time("scrap")
1011
const list = await Project.list()
11-
console.log(list)
12+
process.stdout.write(JSON.stringify(list, null, 2) + EOL)
1213
timer.stop()
1314
},
1415
})

0 commit comments

Comments
 (0)