Sync public tree to cba0ec1
This commit is contained in:
parent
1d72f20cce
commit
2b291e12b7
2 changed files with 34 additions and 18 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"kind": "disasmer-filtered-public-tree",
|
||||
"source_commit": "b67d2a61d1b2a7600593024b4943e155443eb1d7",
|
||||
"release_name": "dryrun-b67d2a61d1b2",
|
||||
"source_commit": "cba0ec1babb581e7e75ad49a57e3cc8c9269d9da",
|
||||
"release_name": "dryrun-cba0ec1babb5",
|
||||
"filtered_out": [
|
||||
"private/**",
|
||||
"experiments/**",
|
||||
|
|
|
|||
|
|
@ -76,12 +76,31 @@ function run(command, args, options = {}) {
|
|||
|
||||
function runJson(command, args, options = {}) {
|
||||
const output = run(command, args, options);
|
||||
const line = output
|
||||
.trim()
|
||||
.split(/\r?\n/)
|
||||
.filter(Boolean)
|
||||
.at(-1);
|
||||
return JSON.parse(line);
|
||||
return parseJsonOutput(output);
|
||||
}
|
||||
|
||||
function parseJsonOutput(output) {
|
||||
const trimmed = output.trim();
|
||||
if (!trimmed) {
|
||||
throw new Error("expected JSON output, got empty stdout");
|
||||
}
|
||||
try {
|
||||
return JSON.parse(trimmed);
|
||||
} catch (_) {
|
||||
// Commands may print progress before their final JSON report. Try each
|
||||
// trailing block so both compact and pretty-printed JSON are accepted.
|
||||
}
|
||||
|
||||
const lines = trimmed.split(/\r?\n/).filter(Boolean);
|
||||
for (let index = lines.length - 1; index >= 0; index -= 1) {
|
||||
try {
|
||||
return JSON.parse(lines.slice(index).join("\n"));
|
||||
} catch (_) {
|
||||
// Keep scanning for the start of the trailing JSON value.
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`could not parse JSON output:\n${trimmed}`);
|
||||
}
|
||||
|
||||
function executable(root, name) {
|
||||
|
|
@ -120,16 +139,13 @@ function waitForJsonLine(child, label) {
|
|||
}, 120000);
|
||||
child.stdout.on("data", (chunk) => {
|
||||
stdout += chunk.toString();
|
||||
for (const line of stdout.split(/\r?\n/)) {
|
||||
if (!line.trim()) continue;
|
||||
try {
|
||||
const parsed = JSON.parse(line);
|
||||
clearTimeout(timer);
|
||||
resolve(parsed);
|
||||
return;
|
||||
} catch (_) {
|
||||
// keep waiting
|
||||
}
|
||||
try {
|
||||
const parsed = parseJsonOutput(stdout);
|
||||
clearTimeout(timer);
|
||||
resolve(parsed);
|
||||
return;
|
||||
} catch (_) {
|
||||
// Keep waiting for a complete JSON value.
|
||||
}
|
||||
});
|
||||
child.stderr.on("data", (chunk) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue