UNPKG

@baseplate-dev/sync

Version:

Library for syncing Baseplate descriptions

45 lines 2.09 kB
interface DirectoryOptions { ignoreFiles?: string[]; } /** * Checks if a directory is empty, optionally ignoring specified files. * * @param dirPath - Path to the directory to check * @param options - Options including ignoreFiles array * @param options.ignoreFiles - Array of file names to ignore when determining if directory is empty * @returns Promise that resolves to true if directory is empty (or only contains ignored files), false otherwise * * @example * // Check if directory is empty, ignoring .gitkeep files * const isEmpty = await isDirectoryEmpty('/path/to/dir', { ignoreFiles: ['.gitkeep'] }); */ export declare function isDirectoryEmpty(dirPath: string, options?: DirectoryOptions): Promise<boolean>; /** * Removes empty ancestor directories starting from the parent directories of the given file paths. * * A directory is considered "empty" if it contains no files, or only contains files that are * specified in the ignoreFiles option. Directories that only contain ignored files will be * removed along with their ignored files. * * The function traverses up the directory tree from each file path's parent directory, * removing empty directories until it encounters: * - A directory that contains non-ignored files * - The specified stop directory * - The filesystem root * * @param filePaths - Array of file paths whose parent directories should be checked for removal * @param stopAt - Directory path to stop at (this directory will not be removed) * @param options - Options including ignoreFiles array * @param options.ignoreFiles - Array of file names to ignore when determining if directory is empty * * @example * // Remove empty directories after deleting files, ignoring .gitkeep files * await removeEmptyAncestorDirectories( * ['/project/src/components/Button.tsx'], * '/project', * { ignoreFiles: ['.gitkeep'] } * ); */ export declare function removeEmptyAncestorDirectories(filePaths: string[], stopAt: string, options?: DirectoryOptions): Promise<void>; export {}; //# sourceMappingURL=directories.d.ts.map