@atomist/automation-client
Version:
Atomist API for software low-level client
60 lines • 2.34 kB
TypeScript
import { CloneDirectoryInfo, CloneOptions, DirectoryManager } from "./DirectoryManager";
/**
* Directory manager that creates temporary directories in the system
* temporary directory. It cleans them up after two hours or on
* program exit, if possible. The class only creates a single
* instance of itself.
*
* It uses tmp-promise (built on tmp) to create clean temporary
* directories to work with git projects from remotes
*/
declare class CleaningTmpDirectoryManager implements DirectoryManager {
readonly root: string;
readonly prefix: string;
private readonly reapInterval;
private readonly maxAge;
private readonly instance;
private initialized;
constructor();
/**
* Create a temporary directory for the provided repository.
*/
directoryFor(owner: string, repo: string, branch: string, opts: CloneOptions): Promise<CloneDirectoryInfo>;
/**
* Initialize object, creating interval for cleanup and
* registering shutdown hook.
*/
private initialize;
private cleanup;
/**
* Remove temporary directories created by this object that pass
* the filter. All operations of this method are wrapped in a
* try/catch block to make it safe for use in timers and
* intervals, although the return value will be ignored in those
* cases.
*
* @param filter If this returns `true` when passed the basename of the temporary directory, the directory will be deleted
* @return 0 if succesful, 1 otherwise
*/
reap(filter?: (d: string) => boolean): Promise<number>;
/**
* Filter for reap that performs no filtering, everything gets
* deleted.
*/
noFilter(d: string): boolean;
/**
* Filter directory on age. The returned function returns true if
* the age of its argument, as determined by the stat mtime, is
* greater than the old, which defaults to 2 hours.
*
* @param old Age beyond which `true` will be returned
* @param now Time to consider the current time, defaults to `Date.now()`
*/
ageFilter(old?: number, now?: number): (d: string) => boolean;
}
/**
* Singleton instance of [[CleaningTmpDirectoryManager]].
*/
export declare const TmpDirectoryManager: CleaningTmpDirectoryManager;
export {};
//# sourceMappingURL=tmpDirectoryManager.d.ts.map