Try spawnSync again
This commit is contained in:
parent
a76049cadd
commit
f7922ef9e1
|
@ -1,4 +1,4 @@
|
||||||
import { spawn } from "child_process";
|
import { spawn, spawnSync } from "child_process";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import process from "process";
|
import process from "process";
|
||||||
|
|
||||||
|
@ -323,54 +323,67 @@ export class Session {
|
||||||
}
|
}
|
||||||
await this.writeCode(code);
|
await this.writeCode(code);
|
||||||
const termArgs = this.privilegedPty(cmdline);
|
const termArgs = this.privilegedPty(cmdline);
|
||||||
const term = {
|
const result = spawnSync(termArgs[0], termArgs.slice(1), {
|
||||||
pty: spawn(termArgs[0], termArgs.slice(1)),
|
encoding: "utf-8",
|
||||||
live: true,
|
});
|
||||||
};
|
|
||||||
this.term = term;
|
|
||||||
|
|
||||||
this.term.pty.stdout.on("data", (data) => {
|
if (result.stderr) {
|
||||||
// Capture term in closure so that we don't keep sending output
|
this.send({
|
||||||
// from the old pty even after it's been killed (see ghci).
|
event: "serviceLog",
|
||||||
if (term.live) {
|
service: "pty",
|
||||||
const output = data.toString("utf8");
|
output: data.stderr,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.send({
|
this.send({
|
||||||
event: "terminalOutput",
|
event: "terminalOutput",
|
||||||
expectedOutput,
|
expectedOutput,
|
||||||
output,
|
output: result.stdout,
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.term.pty.stderr.on("data", (data) => {
|
|
||||||
if (term.live) {
|
|
||||||
this.send({
|
|
||||||
event: "serviceLog",
|
|
||||||
service: "pty",
|
|
||||||
output: data.toString("utf8"),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.term.pty.on("close", (code, signal) => {
|
|
||||||
if (term.live) {
|
|
||||||
this.send({
|
|
||||||
event: "serviceFailed",
|
|
||||||
service: "terminal",
|
|
||||||
error: `Exited with status ${signal || code}`,
|
|
||||||
expectedOutput,
|
|
||||||
code: signal || code,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.term.pty.on("error", (err) => {
|
|
||||||
if (term.live) {
|
|
||||||
this.send({
|
|
||||||
event: "serviceFailed",
|
|
||||||
service: "terminal",
|
|
||||||
error: `${err}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// this.term.pty.stdout.on("data", (data) => {
|
||||||
|
// // Capture term in closure so that we don't keep sending output
|
||||||
|
// // from the old pty even after it's been killed (see ghci).
|
||||||
|
// if (term.live) {
|
||||||
|
// const output = data.toString("utf8");
|
||||||
|
|
||||||
|
// this.send({
|
||||||
|
// event: "terminalOutput",
|
||||||
|
// expectedOutput,
|
||||||
|
// output,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// this.term.pty.stderr.on("data", (data) => {
|
||||||
|
// if (term.live) {
|
||||||
|
// this.send({
|
||||||
|
// event: "serviceLog",
|
||||||
|
// service: "pty",
|
||||||
|
// output: data.toString("utf8"),
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// this.term.pty.on("close", (code, signal) => {
|
||||||
|
// if (term.live) {
|
||||||
|
// this.send({
|
||||||
|
// event: "serviceFailed",
|
||||||
|
// service: "terminal",
|
||||||
|
// error: `Exited with status ${signal || code}`,
|
||||||
|
// expectedOutput,
|
||||||
|
// code: signal || code,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// this.term.pty.on("error", (err) => {
|
||||||
|
// if (term.live) {
|
||||||
|
// this.send({
|
||||||
|
// event: "serviceFailed",
|
||||||
|
// service: "terminal",
|
||||||
|
// error: `${err}`,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logError(err);
|
logError(err);
|
||||||
this.sendError(err);
|
this.sendError(err);
|
||||||
|
|
|
@ -17,6 +17,12 @@ install:
|
||||||
unzip -d "${pkg}/opt/elixir-ls" elixir-ls.zip
|
unzip -d "${pkg}/opt/elixir-ls" elixir-ls.zip
|
||||||
ln -s /opt/elixir-ls/language_server.sh "${pkg}/usr/local/bin/elixir-ls"
|
ln -s /opt/elixir-ls/language_server.sh "${pkg}/usr/local/bin/elixir-ls"
|
||||||
|
|
||||||
|
repl: |
|
||||||
|
iex
|
||||||
|
input: |
|
||||||
|
DELAY: 1
|
||||||
|
123 * 234
|
||||||
|
|
||||||
main: "main.exs"
|
main: "main.exs"
|
||||||
template: |
|
template: |
|
||||||
IO.puts("Hello, world!")
|
IO.puts("Hello, world!")
|
||||||
|
@ -43,5 +49,3 @@ lsp:
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
- lsp
|
- lsp
|
||||||
- repl
|
|
||||||
- runrepl
|
|
||||||
|
|
Loading…
Reference in New Issue