mirror of
https://github.com/joelwmale/webhook-action.git
synced 2024-08-25 08:08:00 +00:00
31 lines
662 B
TypeScript
31 lines
662 B
TypeScript
import * as fs from 'fs';
|
|
|
|
export type FileSystemAdapter = {
|
|
lstat: typeof fs.lstat;
|
|
stat: typeof fs.stat;
|
|
lstatSync: typeof fs.lstatSync;
|
|
statSync: typeof fs.statSync;
|
|
readdir: typeof fs.readdir;
|
|
readdirSync: typeof fs.readdirSync;
|
|
};
|
|
|
|
export const FILE_SYSTEM_ADAPTER: FileSystemAdapter = {
|
|
lstat: fs.lstat,
|
|
stat: fs.stat,
|
|
lstatSync: fs.lstatSync,
|
|
statSync: fs.statSync,
|
|
readdir: fs.readdir,
|
|
readdirSync: fs.readdirSync
|
|
};
|
|
|
|
export function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter {
|
|
if (fsMethods === undefined) {
|
|
return FILE_SYSTEM_ADAPTER;
|
|
}
|
|
|
|
return {
|
|
...FILE_SYSTEM_ADAPTER,
|
|
...fsMethods
|
|
};
|
|
}
|