UNPKG

1.89 kBTypeScriptView Raw
1import { EJSON } from 'bson';
2/**
3 * Provides functionality for manipulating files and directories.
4 */
5export declare class FileSystem {
6 static FILE_NAME_SPLIT_CHARACTER: string;
7 /**
8 * Lists file names for a given path.
9 *
10 * @param path File path
11 */
12 listFileNames(path: string): string[];
13 /**
14 * Lists directories which are not empty or hidden.
15 *
16 * @param path File path
17 */
18 listValidDirectories(path: string): string[];
19 /**
20 * Checks if a directory is empty.
21 *
22 * @param path File path
23 */
24 isEmpty(path: string): boolean;
25 /**
26 * Checks if a file or directory is empty.
27 *
28 * @param fileOrDirectoryName File or directory name
29 */
30 isHidden(fileOrDirectoryName: string): boolean;
31 /**
32 * Checks if a path is a directory.
33 *
34 * @param path File path
35 */
36 isDirectory(path: string): boolean;
37 /**
38 * Filters files which are supported for database seeding.
39 *
40 * @param fileNames Array of file names
41 * @param supportedExtensions Supported file extensions array
42 */
43 filterSupportedDocumentFileNames(fileNames: string[], supportedExtensions: string[]): string[];
44 /**
45 * Checks if a file should be ignored based on extension.
46 *
47 * @param fileNameSplitByDot Array, which comes from file name split by dot
48 */
49 shouldIgnoreFile(fileNameSplitByDot: string[]): boolean;
50 /**
51 * Reads content for multiple files.
52 *
53 * @param paths Array of paths
54 */
55 readFilesContent(paths: string[], ejsonParseOptions: EJSON.Options): any[];
56 /**
57 * Reads a file from path. If it is a JSON, uses EJSON parser.
58 *
59 * @param path File path
60 */
61 readFile(path: string, ejsonParseOptions: EJSON.Options): any;
62}
63/**
64 * Default `FileSystem` instance
65 */
66export declare const fileSystem: FileSystem;