@bscotch/stitch
Version:
Stitch: The GameMaker Studio 2 Asset Pipeline Development Kit.
58 lines • 2.54 kB
TypeScript
/**
* @file GameMaker files and file-system needs have some specificies that
* aren't dealth with by native fs or popular library fs-extra. This module
* should be used for any file system operations, so that only those methods
* that we know won't create problems will be exported and useable (and any
* methods that would create problems can be rewritten).
*/
/// <reference types="node" />
/// <reference types="node" />
import { Pathy } from '@bscotch/pathy';
import { listFilesByExtensionSync, listFilesSync, listFoldersSync, listPathsSync } from '@bscotch/utility';
import fs from 'fs-extra';
declare function isFileSync(filePath: string): boolean;
declare function checksum(filePath: string): Buffer & string;
declare function ensureDirSync(dir: string): void;
/** Write file while ensuring the parent directories exist. */
declare function writeFileSync(filePath: string, stuff: string | Buffer): void;
declare function copyFileSync(source: string, targetPath: string): void;
export interface FileDifferenceFile {
path: string | Pathy;
checksum?: string;
}
export type FileDifferenceType = 'added' | 'deleted' | 'modified';
export interface FileDifference {
areSame: boolean;
change?: FileDifferenceType;
}
/**
* Compare two files and return a high-level description of the difference.
* Checksums are computed if not provided. Files do not have to exist.
*
* Diff interpretation is left compared to right. For example, if `left` exists
* and `right` does not, the `change` type is `"deleted"`.
*/
export declare function compareFilesByChecksum(left: FileDifferenceFile, right: FileDifferenceFile): Promise<FileDifference>;
export declare function fileChecksum(path: Pathy | string): Promise<string>;
declare const _default: {
statSync: fs.StatSyncFn;
fileChecksum: typeof fileChecksum;
existsSync: typeof fs.existsSync;
removeSync: typeof fs.removeSync;
ensureDirSync: typeof ensureDirSync;
copyFileSync: typeof copyFileSync;
checksum: typeof checksum;
mkdirSync: typeof fs.mkdirSync;
copySync: typeof fs.copySync;
emptyDirSync: typeof fs.emptyDirSync;
readFileSync: typeof fs.readFileSync;
writeFileSync: typeof writeFileSync;
listPathsSync: typeof listPathsSync;
listFoldersSync: typeof listFoldersSync;
listFilesSync: typeof listFilesSync;
listFilesByExtensionSync: typeof listFilesByExtensionSync;
isFileSync: typeof isFileSync;
moveSync: typeof fs.moveSync;
};
export default _default;
//# sourceMappingURL=files.d.ts.map