fix(runtime): закрыть fix2 P0 runtime pass без legacy
This commit is contained in:
@@ -48,3 +48,32 @@ export async function runVisible(command: TemplateStringsArray, ...args: unknown
|
||||
throw new Error(`command failed (${exitCode}): ${rendered}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function runHidden(command: TemplateStringsArray, ...args: unknown[]): Promise<void> {
|
||||
const rendered = renderCommand(command, args);
|
||||
const process = Bun.spawn(["sh", "-c", rendered], {
|
||||
stdout: "inherit",
|
||||
stderr: "inherit"
|
||||
});
|
||||
const exitCode = await process.exited;
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(`command failed (${exitCode})`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function runSecret(command: TemplateStringsArray, ...args: unknown[]): Promise<string> {
|
||||
const rendered = renderCommand(command, args);
|
||||
const process = Bun.spawn(["sh", "-c", rendered], {
|
||||
stdout: "pipe",
|
||||
stderr: "pipe"
|
||||
});
|
||||
const [stdout, stderr, exitCode] = await Promise.all([
|
||||
new Response(process.stdout).text(),
|
||||
new Response(process.stderr).text(),
|
||||
process.exited
|
||||
]);
|
||||
if (exitCode !== 0) {
|
||||
throw new Error(`command failed (${exitCode}): ${stderr.trim()}`);
|
||||
}
|
||||
return stdout.trim();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user