Skip to content

Commit 5a1a15e

Browse files
smarterDuhemm
authored andcommitted
Log sbt output, and close stdin so sbt doesn't block on error
1 parent 7370074 commit 5a1a15e

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

vscode-dotty/src/extension.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export function activate(context: ExtensionContext) {
6060
const portFile = path.join(workspaceRoot, ".dotty-ide-dev-port")
6161
fs.readFile(portFile, (err, port) => {
6262
if (err) {
63-
outputChannel.append(`Unable to parse ${portFile}`)
63+
outputChannel.appendLine(`Unable to parse ${portFile}`)
6464
throw err
6565
}
6666

@@ -219,9 +219,15 @@ function runLanguageServer(coursierPath: string, languageServerArtifactFile: str
219219
function startNewSbtInstance(log: vscode.OutputChannel, coursierPath: string) {
220220
fetchWithCoursier(coursierPath, sbtArtifact).then((sbtClasspath) => {
221221
sbtProcess = cpp.spawn("java", [
222+
"-Dsbt.log.noformat=true",
222223
"-classpath", sbtClasspath,
223224
"xsbt.boot.Boot"
224225
]).childProcess
226+
227+
// Close stdin, otherwise in case of error sbt will block waiting for the
228+
// user input to reload or exit the build.
229+
sbtProcess.stdin.end()
230+
225231
sbtProcess.stdout.on('data', data => {
226232
log.append(data.toString())
227233
})
@@ -263,11 +269,15 @@ function fetchWithCoursier(coursierPath: string, artifact: string, extra: string
263269
coursierProc.stdout.on('data', (data: Buffer) => {
264270
classPath += data.toString().trim()
265271
})
272+
coursierProc.stderr.on('data', (data: Buffer) => {
273+
let msg = data.toString().trim()
274+
outputChannel.appendLine(msg)
275+
})
266276

267277
coursierProc.on('close', (code: number) => {
268278
if (code != 0) {
269279
let msg = `Couldn't fetch '${ artifact }' (exit code ${ code }).`
270-
outputChannel.append(msg)
280+
outputChannel.appendLine(msg)
271281
throw new Error(msg)
272282
}
273283
})

0 commit comments

Comments
 (0)