@atomist/automation-client
Version:
Atomist API for software low-level client
69 lines • 3.33 kB
TypeScript
import { File } from "../File";
import { FileStream, Project, ProjectAsync } from "../Project";
/**
* Promise of an array of files. Usually sourced from Project.streamFiles
*/
export declare function toPromise(stream: FileStream): Promise<File[]>;
/**
* Allows conveniently passing one or many glob patterns to utility functions
*/
export declare type GlobOptions = string | string[];
/**
* Does at least one file matching the given predicate exist in this project?
* If no predicate is supplied, does at least one file match the glob pattern?
* No guarantees about ordering
* @param p
* @param globPatterns positive and negative globs to match
* @param test return a boolean or promise. Defaults to true
* @return {Promise<boolean>}
*/
export declare function fileExists<T>(p: ProjectAsync, globPatterns: GlobOptions, test?: (f: File) => (boolean | Promise<boolean>)): Promise<boolean>;
/**
* Count files matching the given predicate in this project
* If no predicate is supplied, does at least one file match the glob pattern?
* No guarantees about ordering
* @param p
* @param globPatterns positive and negative globs to match
* @param test return a boolean or promise. Defaults to true
* @return {Promise<boolean>}
*/
export declare function countFiles<T>(p: ProjectAsync, globPatterns: GlobOptions, test?: (f: File) => (boolean | Promise<boolean>)): Promise<number>;
/**
* Gather values from files
* @param {ProjectAsync} project to act on
* @param {string} globPatterns glob pattern for files to match
* @param {(f: File) => Promise<T>} gather function returning a promise (of the value you're gathering) from each file.
* Undefined returns will be filtered out
* @return {Promise<T[]>}
*/
export declare function gatherFromFiles<T>(project: ProjectAsync, globPatterns: GlobOptions, gather: (f: File) => Promise<T> | undefined): Promise<T[]>;
/**
* Async generator to iterate over files.
* @param {Project} project to act on
* @param {string} globPatterns glob pattern for files to match
* @param filter function to determine whether this file should be included.
* Include all files if this function isn't supplied.
* @return {Promise<T[]>}
*/
export declare function fileIterator(project: Project, globPatterns: GlobOptions, filter?: (f: File) => Promise<boolean>): AsyncIterable<File>;
/**
* Perform the same operation on all the files.
* @param project project to act on
* @param globPatterns glob patterns to match
* @param op operation to perform on files. Can return void or a promise.
*/
export declare function doWithFiles<P extends ProjectAsync>(project: P, globPatterns: GlobOptions, op: (f: File) => void | Promise<any>): Promise<P>;
/**
* Delete files matching the glob pattern and extra test (if supplied)
* @param project project to act on
* @param globPatterns glob patterns for files to delete
* @param test additional, optional test for files to be deleted
*/
export declare function deleteFiles<T>(project: ProjectAsync, globPatterns: GlobOptions, test?: (f: File) => boolean): Promise<number>;
/**
* Copy files from one project to another
* @param from project to copy files from
* @param to project to copy files to
*/
export declare function copyFiles<P extends Project = Project>(from: Project, to: P): Promise<P>;
//# sourceMappingURL=projectUtils.d.ts.map