@tylertech/forge-build-tools
Version:
Node utilities for building and packaging libraries.
97 lines (96 loc) • 4.62 kB
TypeScript
import * as fs from 'fs';
import { GlobOptionsWithFileTypesUnset, globSync } from 'glob';
import fsExtra from 'fs-extra';
export declare const existsSync: (path: string) => boolean;
export declare const mkdirAsync: typeof fs.mkdir.__promisify__;
export declare const mkdirp: typeof fsExtra.ensureDirSync;
export declare const copy: typeof fsExtra.copySync;
export declare const copyAsync: (arg1: string, arg2: string) => Promise<void>;
export declare const symlinkAsync: typeof fs.symlink.__promisify__;
export declare const readFileAsync: typeof fs.readFile.__promisify__;
export declare const writeFileAsync: typeof fs.writeFile.__promisify__;
export declare const existsAsync: typeof fs.exists.__promisify__;
export declare const readdirAsync: typeof fs.readdir.__promisify__;
export declare const statAsync: typeof fs.stat.__promisify__;
export declare const lstatAsync: typeof fs.lstat.__promisify__;
export declare const removeSync: typeof fsExtra.removeSync;
export declare const ensureDir: (arg1: string) => Promise<void>;
export declare const ensureDirSync: typeof fsExtra.ensureDirSync;
export declare const outputFileAsync: typeof fsExtra.outputFile;
export declare const globFiles: typeof globSync;
export declare const emptyDir: typeof fsExtra.emptyDirSync;
export declare const emptyDirAsync: typeof fsExtra.emptyDir;
export declare const deleteDir: (path: string | string[], opt?: import("rimraf").RimrafSyncOptions) => boolean;
export declare const rename: typeof fs.rename.__promisify__;
export declare const deleteFile: typeof fs.unlink.__promisify__;
export declare const moveAsync: (arg1: string, arg2: string) => Promise<void>;
export declare function globFilesAsync(pattern: string | string[], options?: GlobOptionsWithFileTypesUnset | undefined): Promise<string[]>;
/**
* Deletes the list of files.
* @param files The files to delete.
*/
export declare function deleteFiles(files: string | string[]): Promise<void>;
/**
* Moves an array of files or a glob pattern of files to a directory.
* @param {string[] | string} files The array of files or a glob pattern of files to search for.
* @param {string} rootDir The common root directory in which to build the structure in the output directory.
* @param {string} outputDir The output directory path.
*/
export declare function moveFiles(files: string[] | string, rootDir: string | null, outputDir: string): Promise<void>;
/**
*
* @param dirs The directory paths to move.
* @param outputDir The new directory location.
*/
export declare function moveDirectories(dirs: string[], outputDir: string): Promise<void>;
/**
* Copies an array of files or a glob pattern of files to a directory.
* @param {string | string[]} files The array of files or a glob pattern of files to search for.
* @param {string} rootDir The common root directory in which to build the structure in the output directory.
* @param {string | string[]} outputDirs The output directory path.
*/
export declare function copyFilesAsync(files: string | string[], rootDir: string | null, outputDirs: string | string[], ignoredFiles?: string | string[]): Promise<void>;
export interface IFileCopyConfig {
path: string | string[];
outputPath: string;
rootPath?: string;
}
/**
* Copies the provided files from one directory to another.
* @param fileConfigs The file copy descriptors.
*/
export declare function copyFilesMultiple(fileConfigs: IFileCopyConfig[]): Promise<void>;
/**
* Reads in a JSON file and returns an instance of it.
* @param filepath The path to the file to read.
*/
export declare function readJsonFile<T>(filepath: string): Promise<T | undefined>;
/**
* Writes an object to a JSON file.
* Note: overwrites the file, does not merge the JSON contents.
* @param filepath The file path to write to.
* @param data The object to convert to JSON.
*/
export declare function writeJsonFile<T>(filepath: string, data: T): Promise<void>;
/**
* Creates a new temporary directory.
* @param options The options to pass to `tmp`.
*/
export declare function createTempDir(options?: ITempOptions): Promise<ITempDirResult>;
/**
* Replaces the extension in `inPath` with the extension specified in `extension`.
* @param {string} inPath The path to replace the extension in.
* @param {string} extension The new extension.
*/
export declare function replaceExtension(inPath: string, extension: string): string;
export interface ITempOptions {
mode?: number;
prefix?: string;
postfix?: string;
keep?: boolean;
recursiveCleanup?: boolean;
}
export interface ITempDirResult {
path: string;
remove: () => void;
}