Skip to content

Commit 7280967

Browse files
smarterDuhemm
authored andcommitted
Log sbt output, and close stdin so sbt doesn't block on error
1 parent 26cf0f6 commit 7280967

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
@@ -63,7 +63,7 @@ export function activate(context: ExtensionContext) {
6363
const portFile = path.join(workspaceRoot, ".dotty-ide-dev-port")
6464
fs.readFile(portFile, (err, port) => {
6565
if (err) {
66-
outputChannel.append(`Unable to parse ${portFile}`)
66+
outputChannel.appendLine(`Unable to parse ${portFile}`)
6767
throw err
6868
}
6969

@@ -224,9 +224,15 @@ function runLanguageServer(coursierPath: string, languageServerArtifactFile: str
224224
function startNewSbtInstance(log: vscode.OutputChannel, coursierPath: string) {
225225
fetchWithCoursier(coursierPath, sbtArtifact).then((sbtClasspath) => {
226226
sbtProcess = cpp.spawn("java", [
227+
"-Dsbt.log.noformat=true",
227228
"-classpath", sbtClasspath,
228229
"xsbt.boot.Boot"
229230
]).childProcess
231+
232+
// Close stdin, otherwise in case of error sbt will block waiting for the
233+
// user input to reload or exit the build.
234+
sbtProcess.stdin.end()
235+
230236
sbtProcess.stdout.on('data', data => {
231237
log.append(data.toString())
232238
})
@@ -268,11 +274,15 @@ function fetchWithCoursier(coursierPath: string, artifact: string, extra: string
268274
coursierProc.stdout.on('data', (data: Buffer) => {
269275
classPath += data.toString().trim()
270276
})
277+
coursierProc.stderr.on('data', (data: Buffer) => {
278+
let msg = data.toString().trim()
279+
outputChannel.appendLine(msg)
280+
})
271281

272282
coursierProc.on('close', (code: number) => {
273283
if (code != 0) {
274284
let msg = `Couldn't fetch '${ artifact }' (exit code ${ code }).`
275-
outputChannel.append(msg)
285+
outputChannel.appendLine(msg)
276286
throw new Error(msg)
277287
}
278288
})

0 commit comments

Comments
 (0)