mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
* Open with proper perms when redirecting file to stdin * Add test for redirecting file to stdin * Extract redirect flags -> bun.Mode logic to function * Remove dead code * Support duplicating output file descriptors * Clean up * fix merge fuck up * Add comment documenting weird hack to get around ordering of posix spawn actions * Update docs * Delete dead code * Update docs
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { describe, test, afterAll, beforeAll, expect } from "bun:test";
|
|
import { ShellOutput } from "bun";
|
|
import { ShellPromise } from "bun";
|
|
import { tempDirWithFiles } from "harness";
|
|
import { join } from "node:path";
|
|
import * as fs from "node:fs";
|
|
import { TestBuilder } from "./test_builder";
|
|
|
|
export { TestBuilder };
|
|
|
|
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[] =>
|
|
output
|
|
.split("\n")
|
|
.filter(s => s.length > 0)
|
|
.sort();
|