mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
33 lines
938 B
TypeScript
33 lines
938 B
TypeScript
import { ShellOutput, ShellPromise } from "bun";
|
|
import { createTestBuilder } from "./test_builder";
|
|
|
|
export { createTestBuilder };
|
|
|
|
declare module "bun" {
|
|
// Define the additional methods
|
|
interface Shell {
|
|
parse: (strings: TemplateStringsArray, ...expressions: any[]) => string; // Define the return type for parse
|
|
lex: (strings: TemplateStringsArray, ...expressions: any[]) => string; // Define the return type for lex
|
|
}
|
|
}
|
|
|
|
const defaultRedirect = {
|
|
__unused: 0,
|
|
append: false,
|
|
stderr: false,
|
|
stdin: false,
|
|
stdout: false,
|
|
duplicate_out: false,
|
|
};
|
|
|
|
export const redirect = (opts?: Partial<typeof defaultRedirect>): typeof defaultRedirect =>
|
|
opts === undefined
|
|
? defaultRedirect
|
|
: {
|
|
...defaultRedirect,
|
|
...opts,
|
|
};
|
|
|
|
export const sortedShellOutput = (output: string | string[]): string[] =>
|
|
(Array.isArray(output) ? output : output.split("\n").filter(s => s.length > 0)).sort();
|