@surface/rwx
Version:
Provides read, write and execute capabilities.
84 lines (83 loc) • 3.7 kB
TypeScript
/// <reference types="node" resolution-mode="require"/>
/// <reference types="node" resolution-mode="require"/>
import child_process from "child_process";
import { type Options } from "@surface/path-matcher";
/**
* Asynchronous enumerate paths using given patterns.
* @param patterns Patterns to match. Strings prefixed with "!" will be negated.
* @param options Options to parse patterns.
*/
export declare function enumeratePaths(patterns: string | string[], options?: Options): AsyncGenerator<string>;
/**
* enumerate paths using given patterns.
* @param patterns Patterns to match. Strings prefixed with "!" will be negated.
* @param options Options to parse patterns.
*/
export declare function enumeratePathsSync(patterns: string | string[], options?: Options): Generator<string>;
/**
* Spawns a shell then executes the command within that shell.
* @param command string passed to the exec function and processed directly by the shell and special characters (vary based on shell) need to be dealt with accordingly:
*/
export declare function execute(command: string, options?: child_process.ExecOptions & {
silent?: boolean;
}): Promise<Buffer>;
/**
* Asynchronous Verifies if a path is a directory.
* @param path Path to verify. If a URL is provided, it must use the `file:` protocol.
*/
export declare function isDirectory(path: string): Promise<boolean>;
/**
* Verifies if a path is a directory.
* @param path Path to verify. If a URL is provided, it must use the `file:` protocol.
*/
export declare function isDirectorySync(path: string): boolean;
/**
* Verifies if a path is a file.
* @param path Path to verify. If a URL is provided, it must use the `file:` protocol.
*/
export declare function isFile(path: string): Promise<boolean>;
/**
* Verifies if a path is a file.
* @param path Path to verify. If a URL is provided, it must use the `file:` protocol.
*/
export declare function isFileSync(path: string): boolean;
/**
* Verifies if a path is a symbolic link.
* @param path Path to verify. If a URL is provided, it must use the `file:` protocol.
*/
export declare function isSymbolicLink(path: string): Promise<boolean>;
/**
* Verifies if a path is a symbolic link.
* @param path Path to verify. If a URL is provided, it must use the `file:` protocol.
*/
export declare function isSymbolicLinkSync(path: string): boolean;
/**
* Asynchronous list paths using given patterns.
* @param pattern Pattern to match.
* @param cwd Working dir.
*/
export declare function listPaths(pattern: string | string[], options?: Options): Promise<string[]>;
/**
* List paths using given patterns.
* @param pattern Pattern to match.
* @param cwd Working dir.
*/
export declare function listPathsSync(pattern: string | string[], options?: Options): string[];
/**
* Asynchronous resolve and returns the path of the first resolved file and null otherwise.
* @param files Files to look.
* @param context Context used to resolve.
*/
export declare function lookup(files: string[], context?: string): Promise<string | null>;
/**
* Resolve and returns the path of the first resolved file and null otherwise.
* @param files Files to look.
* @param context Context used to resolve.
*/
export declare function lookupSync(files: string[], context?: string): string | null;
/**
* Looks from bottom to up for the target file/directory.
* @param startPath Path to start resolution. If a URL is provided, it must use the `file:` protocol.
* @param target Target file/directory.
*/
export declare function searchAbove(startPath: string, target: string): string | null;