@sinclair/hammer
Version:
Build Tool for Browser and Node Applications
58 lines (57 loc) • 2.25 kB
TypeScript
import { SystemError } from './error';
export declare class FolderError extends SystemError {
readonly operation: string;
readonly reason: string;
constructor(operation: string, reason: string);
}
export declare class Folder {
private readonly folderPath;
constructor(folderPath: string);
/** Returns an interface to interact with a folders contents. */
contents(): Contents;
/**
* Copies a file or folder into this folder. If this folder does not exist, it will be created.
* Any existing files copied into this folder will be overwritten.
*/
add(systemPath: string): Promise<void>;
/** Copies this folder to a target folder. */
copy(folderPath: string): Promise<void>;
/** Creates this folder. If the folder exists, no action. */
create(): Promise<void>;
/** Deletes this folder. If the folder does not exist, no action. */
delete(): Promise<void>;
/** Returns true if this folder exists. */
exists(): Promise<boolean>;
/** Moves this folder to a target folder. */
move(folderPath: string): Promise<void>;
/** Renames this folder. */
rename(newName: string): Promise<void>;
/** Returns the size of this folder in bytes. */
size(): Promise<number>;
/** Returns a stats object for this folder. */
stat(): Promise<void>;
/** Asserts the given system path exists. */
private assertExists;
private checkExists;
private createFolder;
/** Recursively enumerates all files within this directory. */
private enumerateFiles;
}
export declare class ContentsError extends SystemError {
readonly operation: string;
readonly reason: string;
constructor(operation: string, reason: string);
}
export declare class Contents {
private folderPath;
constructor(folderPath: string);
/** Copies the contents for this folder into a target folder. */
copy(folderPath: string): Promise<void>;
/** Copies the contents for this folder into a target folder. */
move(folderPath: string): Promise<void>;
private createFolder;
private assertExists;
private checkExists;
}
/** Returns an interface to interact with a folder. */
export declare function folder(folderPath: string): Folder;