@socketsecurity/lib
Version:
Core utilities and infrastructure for Socket.dev security tools
78 lines (77 loc) • 2.88 kB
TypeScript
/**
* Execute a binary with the given arguments.
*/
/*@__NO_SIDE_EFFECTS__*/
export declare function execBin(binPath: string, args?: string[], options?: import('./spawn').SpawnOptions): Promise<{
cmd: string;
args: string[] | readonly string[];
code: number;
signal: NodeJS.Signals;
stdout: string | Buffer<ArrayBufferLike>;
stderr: string | Buffer<ArrayBufferLike>;
}>;
/**
* Options for the which function.
*/
export interface WhichOptions {
/** If true, return all matches instead of just the first one. */
all?: boolean | undefined;
/** If true, return null instead of throwing when no match is found. */
nothrow?: boolean | undefined;
/** Path to search in. */
path?: string | undefined;
/** Path separator character. */
pathExt?: string | undefined;
/** Environment variables to use. */
env?: Record<string, string | undefined> | undefined;
}
/**
* Find an executable in the system PATH asynchronously.
* Wrapper around the which package for lazy loading.
*/
/* c8 ignore start */
export declare function which(binName: string, options?: WhichOptions): Promise<string | string[] | undefined>;
/* c8 ignore stop */
/**
* Find an executable in the system PATH synchronously.
* Wrapper around the which package for lazy loading.
*/
/* c8 ignore start */
export declare function whichSync(binName: string, options?: WhichOptions): string | string[] | undefined;
/* c8 ignore stop */
/**
* Find and resolve a binary in the system PATH asynchronously.
* @throws {Error} If the binary is not found and nothrow is false.
*/
export declare function whichBin(binName: string, options?: WhichOptions): Promise<string | string[] | undefined>;
/**
* Find and resolve a binary in the system PATH synchronously.
* @throws {Error} If the binary is not found and nothrow is false.
*/
export declare function whichBinSync(binName: string, options?: WhichOptions): string | string[] | undefined;
/**
* Check if a directory path contains any shadow bin patterns.
*/
export declare function isShadowBinPath(dirPath: string | undefined): boolean;
/**
* Find the real executable for a binary, bypassing shadow bins.
*/
export declare function findRealBin(binName: string, commonPaths?: string[]): string | undefined;
/**
* Find the real npm executable, bypassing any aliases and shadow bins.
*/
export declare function findRealNpm(): string;
/**
* Find the real pnpm executable, bypassing any aliases and shadow bins.
*/
export declare function findRealPnpm(): string;
/**
* Find the real yarn executable, bypassing any aliases and shadow bins.
*/
export declare function findRealYarn(): string;
/*@__NO_SIDE_EFFECTS__*/
/**
* Resolve a binary path to its actual executable file.
* Handles Windows .cmd wrappers and Unix shell scripts.
*/
export declare function resolveBinPathSync(binPath: string): string;