UNPKG

@summarisation/fileutils

Version:

fileutils for summarisation

33 lines (32 loc) 1.29 kB
/// <reference types="node" /> import { ErrorsAnd } from "@laoban/utils"; export interface SuccessfulShellResult { message: string; code: 0; } export declare function isSuccessfulShellResult(t: ShellResult): t is SuccessfulShellResult; export interface FailedShellResult { message?: string; error: string; code: number; } export type ShellResult = SuccessfulShellResult | FailedShellResult; export type ExecuteConfig = { encoding?: BufferEncoding; dryRun?: boolean; debug?: boolean; }; export type ExecuteConfigWithShell = ExecuteConfig & { executeInShell?: ExecuteInShellFn; }; export type ExecuteInShellFn = (cwd: string, cmd: string, config: ExecuteConfig) => Promise<ShellResult>; export declare const executeScriptInShell: ExecuteInShellFn; export declare function execute(cwd: string, cmd: string, config?: ExecuteConfigWithShell): Promise<ErrorsAnd<string>>; export declare function executeRecursivelyInChildDirectories(cwd: string, cmds: string, config?: ExecuteConfigWithShell): Promise<{ executed: number; failed: string[]; }>; export declare function executeRecursivelyCmdChanges(cwd: string, startDir: string, cmdFn: (dir: string) => string, config?: ExecuteConfigWithShell): Promise<{ executed: number; failed: string[]; }>;