Fix tryProcess on C#

This commit is contained in:
2023-02-11 15:42:56 -07:00
parent 688c9b8b71
commit 7e023d6167

View File

@@ -721,28 +721,33 @@ class Prelude {
#end #end
Sys.setCwd(cwd); Sys.setCwd(cwd);
} }
var p = new Process(command, args); try {
if (inputLines != null) { var p = new Process(command, args);
for (line in inputLines) { if (inputLines != null) {
p.stdin.writeString('$line\n'); for (line in inputLines) {
p.stdin.writeString('$line\n');
}
} }
} var output = if (fullProcess) {
var output = if (fullProcess) { if (p.exitCode() == 0) {
if (p.exitCode() == 0) { p.stdout.readAll().toString().trim();
p.stdout.readAll().toString().trim(); } else {
handleError('process $command $args failed:\n${p.stdout.readAll().toString().trim() + p.stderr.readAll().toString().trim()}');
return "";
}
} else { } else {
handleError('process $command $args failed:\n${p.stdout.readAll().toString().trim() + p.stderr.readAll().toString().trim()}'); p.stdout.readLine().toString().trim();
return "";
} }
} else { p.kill();
p.stdout.readLine().toString().trim(); p.close();
if (cwd != null) {
Sys.setCwd(lastCwd);
}
return output;
} catch (e) {
handleError('process $command $args failed: $e');
return "";
} }
p.kill();
p.close();
if (cwd != null) {
Sys.setCwd(lastCwd);
}
return output;
#elseif hxnodejs #elseif hxnodejs
var p = if (inputLines != null) { var p = if (inputLines != null) {
ChildProcess.spawnSync(command, args, {input: inputLines.join("\n"), cwd: cwd}); ChildProcess.spawnSync(command, args, {input: inputLines.join("\n"), cwd: cwd});