/** * Helper functions for file operations. * * @module */ /** Helper function to throw an error if the provided path is not a directory. */ export declare function assertDirectory(directoryPath: string, msg: string): Promise; /** Helper function to throw an error if the provided path is not a file. */ export declare function assertFile(filePath: string, msg: string): Promise; /** * Helper function to asynchronously copy a file or directory. If a path to a directory is * specified, the directory will be recursively copied. * * @throws If the file cannot be copied. */ export declare function copyFileOrDirectory(srcPath: string, dstPath: string): Promise; /** * Helper function to asynchronously copy a file or directory. If a path to a directory is * specified, the directory will be recursively copied. * * This is an alias for the `copyFileOrDirectory` function. (It is intended to be used in scripts.) * * @throws If the file cannot be copied. */ export declare function cp(srcPath: string, dstPath: string): Promise; /** * Helper function to asynchronously delete a file or directory. If a path to a directory is * specified, the directory will be recursively deleted. If the path does not exist, this function * will be a no-op. * * This function is variadic, meaning that you can pass as many file paths as you want to delete. * * @throws If the file cannot be deleted. */ export declare function deleteFileOrDirectory(...filePaths: readonly string[]): Promise; /** * Helper function to see if the given file path exists. This will work with files, directories, * links, and so on. */ export declare function exists(filePath: string): Promise; /** * Helper function to get a SHA1 hash for every file in a directory. (This function correctly * handles nested subdirectories.) * * This is useful to see if the contents of a directory have changed in any way. * * @throws If there is an error when checking the directory. */ export declare function getDirectoryHashSHA1(directoryPath: string): Promise; /** * Helper function to get the SHA1 hash of a file. * * @throws If there is an error when reading the file. */ export declare function getFileHashSHA1(filePath: string): Promise; /** * Helper function to asynchronously get the file names or file paths inside of a directory. * * @param directoryPath The path to the directory. * @param filter Optional. If specified, will only return this type of file. * @param recursive Optional. If true, will include files in all subdirectories. Default is false. * @param paths Optional. If true, will return the full file paths instead of just the file names. * Default is false. * @throws If there is an error when checking the directory. */ export declare function getFileNamesInDirectory(directoryPath: string, filter?: "files" | "directories", recursive?: boolean, paths?: boolean): Promise; /** * Helper function to synchronously get the path to file, given either a file path, a directory * path, or `undefined`. * * @param fileName The name of the file to find. * @param filePathOrDirPath Either the path to a file or the path to a directory which contains the * file. If undefined is passed, the current working directory will be * used. * @throws If the file cannot be found. */ export declare function getFilePath(fileName: string, filePathOrDirPath: string | undefined): Promise; /** * Helper function to asynchronously get the file paths inside of a directory. * * @param directoryPath The path to the directory. * @param filter Optional. If specified, will only return this type of file. Defaults to returning * both files and directories. * @param recursive Optional. If true, will include files in all subdirectories. Default is false. * @throws If there is an error when checking the directory. */ export declare function getFilePathsInDirectory(directoryPath: string, filter?: "files" | "directories", recursive?: boolean): Promise; /** Helper function to asynchronously check if the provided path exists and is a directory. */ export declare function isDirectory(filePath: string): Promise; /** Helper function to asynchronously check if the provided path exists and is a file. */ export declare function isFile(filePath: string): Promise; /** * Helper function to see if a directory is the root directory of the file system. * * Under the hood, this uses `path.normalize` and `path.dirname` to determine this. */ export declare function isFileSystemRootDirectory(directoryPath: string): boolean; /** Helper function to asynchronously check if the provided path exists and is a symbolic link. */ export declare function isLink(filePath: string): Promise; /** Helper function to see if a directory is a subdirectory of another one. */ export declare function isSubdirectoryOf(directoryPath: string, parentPath: string): boolean; /** * Helper function to asynchronously make a new directory. By default, it will recursively make as * many subdirectories as needed. If the directory already exists, this function will be a no-op. * * @param directoryPath The path to the directory to create. * @param recursive Optional. Default is true. * @throws If the directory cannot be created. */ export declare function makeDirectory(directoryPath: string, recursive?: boolean): Promise; /** * Helper function to asynchronously make a new directory. By default, it will recursively make as * many subdirectories as needed. If the directory already exists, this function will be a no-op. * * This is an alias for the `makeDirectory` function. (It is intended to be used in scripts.) * * @param directoryPath The path to the directory to create. * @param recursive Optional. Default is true. * @throws If the directory cannot be created. */ export declare function mkdir(directoryPath: string, recursive?: boolean): Promise; /** * Helper function to move all files from one directory to another one. * * @throws If a file cannot be moved. */ export declare function moveAllFilesInDirectory(srcDirectory: string, dstDirectory: string): Promise; /** * Helper function to asynchronously move a file or directory. * * This is an alias for the `renameFileOrDirectory` function, since the Node.js API uses the same * thing for both operations. * * @throws If the file cannot be moved. */ export declare function moveFileOrDirectory(srcPath: string, dstPath: string): Promise; /** * Helper function to asynchronously move a file or directory. * * This is an alias for the `moveFileOrDirectory` function. (It is intended to be used in scripts.) * * @throws If the file cannot be moved. */ export declare function mv(srcPath: string, dstPath: string): Promise; /** * Helper function to recursively rename all of the files in a directory from one file extension to * another. * * @param directoryPath The path to the directory to crawl. * @param srcFileExtension The file extension to change from. Do not include a period in the string. * @param dstFileExtension The file extension to change to. Do not include a period in the string. * @throws If a file cannot be renamed. */ export declare function renameFileExtensions(directoryPath: string, srcFileExtension: string, dstFileExtension: string): Promise; /** * Helper function to asynchronously rename a file or directory. Since renames are not allowed * across file system boundaries, this will automatically handle that special case by performing a * recursive copy and delete operation instead. * * @throws If the file or directory cannot be renamed. */ export declare function renameFileOrDirectory(srcPath: string, dstPath: string): Promise; /** * Helper function to asynchronously delete a file or directory. If a path to a directory is * specified, the directory will be recursively deleted. If the path does not exist, this function * will be a no-op. * * This function is variadic, meaning that you can pass as many file paths as you want to delete. * * This is an alias for the `deleteFileOrDirectory` function. (It is intended to be used in * scripts.) * * @throws If the file cannot be deleted. */ export declare function rm(...filePaths: readonly string[]): Promise; /** * Helper function to asynchronously write 0 bytes to a file, similar to the `touch` command. * * @throws If the file cannot be touched. */ export declare function touch(filePath: string): Promise; //# sourceMappingURL=file.d.ts.map