1 | /// <reference types="node" />
|
2 |
|
3 | /**
|
4 | * @param pathToCache - the path to the cache file (this combines the cache name and directory
|
5 | * @param useCheckSum - Whether to use md5 checksum to verify if file changed.
|
6 | * If false the default will be to use the mtime and size of the file
|
7 | */
|
8 | export function createFromFile(pathToCache: string, useCheckSum?: boolean): FileEntryCache;
|
9 |
|
10 | /**
|
11 | * @param cacheName - the name of the cache to be created
|
12 | * @param directory - the directory to load the cache from
|
13 | * @param usecheckSum - Whether to use md5 checksum to verify if file changed.
|
14 | * If false the default will be to use the mtime and size of the file
|
15 | */
|
16 | export function create(cacheName: string, directory?: string, usecheckSum?: boolean): FileEntryCache;
|
17 |
|
18 | export interface FileEntryCache {
|
19 | /** the flat cache storage used to persist the metadata of the `files */
|
20 | cache: object;
|
21 | /** Given a buffer, calculate md5 hash of its content. */
|
22 | getHash(buffer: Buffer): string;
|
23 | /** Return whether or not a file has changed since last time reconcile was called */
|
24 | hasFileChanged(file: string): boolean;
|
25 | /**
|
26 | * given an array of file paths it return and object with three arrays:
|
27 | * - changedFiles: Files that changed since previous run
|
28 | * - notChangedFiles: Files that haven't change
|
29 | * - notFoundFiles: Files that were not found, probably deleted
|
30 | */
|
31 | analyzeFiles(files?: string[]): AnalyzedFilesInfo;
|
32 | getFileDescriptor(file: string): FileDescriptor;
|
33 | /**
|
34 | * Return the list o the files that changed compared
|
35 | * against the ones stored in the cache
|
36 | */
|
37 | getUpdatedFiles(files?: string[]): string[];
|
38 | /**
|
39 | * return the list of file
|
40 | */
|
41 | normalizeEntries(files?: string[]): FileDescriptor[];
|
42 | /**
|
43 | * Remove an entry from the file-entry-cache.
|
44 | * Useful to force the file to still be considered
|
45 | * modified the next time the process is run
|
46 | */
|
47 | removeEntry(entryName: string): void;
|
48 | /**
|
49 | * Delete the cache file from the disk
|
50 | */
|
51 | deleteCacheFile(): void;
|
52 | /**
|
53 | * remove the cache from the file and clear the memory cache
|
54 | */
|
55 | destroy(): void;
|
56 | /**
|
57 | * Sync the files and persist them to the cache
|
58 | */
|
59 | reconcile(noPrune?: boolean): void;
|
60 | }
|
61 |
|
62 | export interface AnalyzedFilesInfo {
|
63 | readonly changedFiles: string[];
|
64 | readonly notFoundFiles: string[];
|
65 | readonly notChangedFiles: string[];
|
66 | }
|
67 |
|
68 | export interface FileDescriptor {
|
69 | readonly key: string;
|
70 | readonly notFound: boolean;
|
71 | readonly err?: Error | undefined;
|
72 | readonly changed?: boolean | undefined;
|
73 | readonly meta?: {
|
74 | readonly size?: number | undefined;
|
75 | readonly mtime?: number | undefined;
|
76 | readonly hash?: string | undefined;
|
77 | } | undefined;
|
78 | }
|