@ts-common/azure-js-dev-tools
Version:
Developer dependencies for TypeScript related projects
186 lines • 9.67 kB
TypeScript
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
/**
* Get whether or not a file entry (file or folder) exists at the provided entryPath.
* @param entryPath The path to the file entry to check.
* @returns Whether or not a file entry (file or folder) exists at the provided entryPath.
*/
export declare function entryExists(entryPath: string): Promise<boolean>;
/**
* Check whether or not a symbolic link exists at the provided path.
* @param symbolicLinkPath The path to check.
* @returns Whether or not a symbolic link exists at the provided path.
*/
export declare function symbolicLinkExists(symbolicLinkPath: string): Promise<boolean>;
/**
* Check whether or not a file exists at the provided filePath.
* @param filePath The path to check.
* @returns Whether or not a file exists at the provided filePath.
*/
export declare function fileExists(filePath: string): Promise<boolean>;
/**
* Check whether or not a file exists at the provided filePath.
* @param filePath The path to check.
* @returns Whether or not a file exists at the provided filePath.
*/
export declare function fileExistsSync(filePath: string): boolean;
/**
* Check whether or not a folder exists at the provided folderPath.
* @param folderPath The path to check.
* @returns Whether or not a folder exists at the provided folderPath.
*/
export declare function folderExists(folderPath: string): Promise<boolean>;
export declare function _createFolder(folderPath: string): Promise<boolean>;
/**
* Create a folder at the provided folderPath. If the folder is successfully created, then true will
* be returned. If the folder already exists, then false will be returned.
* @param folderPath The path to create a folder at.
*/
export declare function createFolder(folderPath: string): Promise<boolean>;
/**
* Create a temporary folder and return the absolute path to the folder. If a parentFolderPath is
* provided, then the temporary folder will be created as a child of the parentFolderPath. If
* parentFolderPath is not provided, then the current working folder will be used as the
* parentFolderPath.
* @param The folder that the temporary folder will be created as a child of. Defaults to the
* current working folder.
*/
export declare function createTemporaryFolder(parentFolderPath?: string): Promise<string>;
/**
* Copy the entry at the source entry path to the destination entry path.
* @param sourceEntryPath The path to the entry to copy from.
* @param destinationEntryPath The path to entry to copy to.
*/
export declare function copyEntry(sourceEntryPath: string, destinationEntryPath: string): Promise<void>;
/**
* Copy the file at the source file path to the destination file path.
* @param sourceFilePath The path to the file to copy from.
* @param destinationFilePath The path to file to copy to.
* @param createDestinationFolder Whether or not the destination parent folder will be created if it
* doesn't exist.
*/
export declare function copyFile(sourceFilePath: string, destinationFilePath: string, createDestinationFolder?: boolean): Promise<void>;
/**
* Copy the folder at the source folder path to the destination folder path.
* @param sourceFolderPath The path to the folder to copy from.
* @param destinationFolderPath The path to the folder to copy to. This folder and its parent
* folders will be created if they don't already exist.
*/
export declare function copyFolder(sourceFolderPath: string, destinationFolderPath: string): Promise<void>;
export declare function findEntryInPath(entryName: string | RegExp, startFolderPath: string | undefined, condition: (entryPath: string) => (boolean | Promise<boolean>)): Promise<string | undefined>;
/**
* Find the closest file with the provided name by searching the immediate child folders of the
* folder at the provided startFolderPath. If no file is found with the provided fileName, then the
* search will move up to the parent folder of the startFolderPath. This will continue until either
* the file is found, or the folder being searched does not have a parent folder (if it is a root
* folder).
* @param fileName The name of the file to look for.
* @param startFolderPath The path to the folder where the search will begin.
* @returns The path to the closest file with the provided fileName, or undefined if no file could
* be found.
*/
export declare function findFileInPath(fileName: string | RegExp, startFolderPath?: string): Promise<string | undefined>;
/**
* Find the closest file with the provided name by searching the immediate child folders of the
* folder at the provided startFolderPath. If no file is found with the provided fileName, then the
* search will move up to the parent folder of the startFolderPath. This will continue until either
* the file is found, or the folder being searched does not have a parent folder (if it is a root
* folder).
* @param fileName The name of the file to look for.
* @param startFolderPath The path to the folder where the search will begin.
* @returns The path to the closest file with the provided fileName, or undefined if no file could
* be found.
*/
export declare function findFileInPathSync(fileName: string, startFolderPath?: string): string | undefined;
/**
* Find the closest folder with the provided name by searching the immediate child folders of the
* folder at the provided startFolderPath. If no folder is found with the provided folderName, then
* the search will move up to the parent folder of the startFolderPath. This will continue until
* either the folder is found, or the folder being searched does not have a parent folder (it is a
* root folder).
* @param folderName The name of the folder to look for.
* @param startFolderPath The path to the folder where the search will begin.
* @returns The path to the closest folder with the provided folderName, or undefined if no folder
* could be found.
*/
export declare function findFolderInPath(folderName: string | RegExp, startFolderPath?: string): Promise<string | undefined>;
/**
* Optional parameters to the getChildFilePaths() function.
*/
export interface GetChildEntriesOptions {
/**
* Whether or not to search sub-folders of the provided folderPath.
*/
recursive?: boolean | ((folderPath: string) => (boolean | Promise<boolean>));
/**
* A condition that a child entry path must pass before it will be added to the result.
*/
condition?: (entryPath: string) => (boolean | Promise<boolean>);
/**
* A condition that a child file path must pass before it will be added to the result.
*/
fileCondition?: (filePath: string) => (boolean | Promise<boolean>);
/**
* A condition that a child folder path must pass before it will be added to the result.
*/
folderCondition?: (folderPath: string) => (boolean | Promise<boolean>);
/**
* The array where the matching child folder paths will be added.
*/
result?: string[];
}
/**
* Get the child entries of the folder at the provided folderPath. If the provided folder doesn't
* exist, then undefined will be returned.
* @param folderPath The path to the folder.
* @returns The paths to the child entries of the folder at the provided folder path, or undefined
* if the folder at the provided folder path doesn't exist.
*/
export declare function getChildEntryPaths(folderPath: string, options?: GetChildEntriesOptions): Promise<string[] | undefined>;
/**
* Get the child folders of the folder at the provided folderPath. If the provided folder doesn't
* exist, then undefined will be returned.
* @param folderPath The path to the folder.
* @returns The paths to the child folders of the folder at the provided folder path, or undefined
* if the folder at the provided folder path doesn't exist.
*/
export declare function getChildFolderPaths(folderPath: string, options?: GetChildEntriesOptions): Promise<string[] | undefined>;
/**
* Get the child folders of the folder at the provided folderPath. If the provided folder doesn't
* exist, then undefined will be returned.
* @param folderPath The path to the folder.
* @returns The paths to the child folders of the folder at the provided folder path, or undefined
* if the folder at the provided folder path doesn't exist.
*/
export declare function getChildFilePaths(folderPath: string, options?: GetChildEntriesOptions): Promise<string[] | undefined>;
/**
* Read the contents of the provided file.
* @param filePath The path to the file to read.
*/
export declare function readFileContents(filePath: string): Promise<string | undefined>;
/**
* Write the provided contents to the file at the provided filePath.
* @param filePath The path to the file to write.
* @param contents The contents to write to the file.
*/
export declare function writeFileContents(filePath: string, contents: string): Promise<void>;
export declare function deleteEntry(path: string): Promise<boolean>;
/**
* Delete the file at the provided file path.
* @param {string} filePath The path to the file to delete.
*/
export declare function deleteFile(filePath: string): Promise<boolean>;
/**
* Delete each of the provided file paths.
* @param filePaths The file paths that should be deleted.
*/
export declare function deleteFiles(...filePaths: string[]): Promise<void>;
/**
* Delete the folder at the provided folder path.
* @param {string} folderPath The path to the folder to delete.
*/
export declare function deleteFolder(folderPath: string): Promise<boolean>;
//# sourceMappingURL=fileSystem2.d.ts.map