UNPKG

dax

Version:

Cross platform shell tools inspired by zx.

85 lines 3.11 kB
import * as fs from "node:fs"; import type { Reader } from "./pipes.js"; export declare const isWindows: boolean; /** A snapshot of `process.env` with `undefined` values filtered out. */ export declare function getRealEnvVars(): Record<string, string>; interface Symbols { /** Use this symbol to enable the provided object to be written to in * an output redirect within a template literal expression. * * @example * ```ts * class MyClass { * [$.symbols.writable](): WritableStream<Uint8Array> { * // return a WritableStream here * } * } * const myObj = new MyClass(); * await $`echo 1 > ${myObj}`; * ``` */ readonly writable: symbol; /** Use this symbol to enable the provided object to be read from in * an input redirect within a template literal expression. * * @example * ```ts * class MyClass { * [$.symbols.readable](): ReadableStream<Uint8Array> { * // return a ReadableStream here * } * } * const myObj = new MyClass(); * await $`gzip < ${myObj}`; * ``` */ readonly readable: symbol; } export declare const symbols: Symbols; /** * Delay used for certain actions. * * @remarks Providing just a number will use milliseconds. */ export type Delay = number | `${number}ms` | `${number}s` | `${number}m` | `${number}m${number}s` | `${number}h` | `${number}h${number}m` | `${number}h${number}m${number}s`; /** Converts a {@link Delay} value into the equivalent number of milliseconds. */ export declare function delayToMs(delay: Delay): number; export declare function resolvePath(cwd: string, arg: string): string; export declare class Box<T> { value: T; constructor(value: T); } export declare class TreeBox<T> { #private; constructor(value: T | TreeBox<T>); getValue(): T; setValue(value: T): void; createChild(): TreeBox<T>; } /** A special kind of tree box that wraps logging so that terminal static * text (e.g. a host's progress bars) is momentarily cleared during writes. */ export declare class LoggerTreeBox extends TreeBox<(...args: any[]) => void> { getValue(): (...args: any[]) => void; } /** lstat that doesn't throw when the path is not found. */ export declare function safeLstat(path: string): Promise<fs.Stats | undefined>; /** * Gets an executable shebang from the provided file path. * @returns * - An object outlining information about the shebang. * - `undefined` if the file exists, but doesn't have a shebang. * - `false` if the file does NOT exist. */ export declare function getExecutableShebangFromPath(path: string): Promise<false | ShebangInfo | undefined>; export interface ShebangInfo { stringSplit: boolean; command: string; } export declare function getExecutableShebang(reader: Reader): Promise<ShebangInfo | undefined>; export declare function abortSignalToPromise(signal: AbortSignal): { [Symbol.dispose](): void; promise: Promise<void>; }; export declare function errorToString(err: unknown): string; export {}; //# sourceMappingURL=common.d.ts.map