1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Handle copy as part of fake FS

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-12-02 16:10:59 -05:00
parent f7c3657e60
commit af48b7de5f
2 changed files with 7 additions and 1 deletions

View File

@ -29,6 +29,7 @@ const fsInjectable = getInjectable({
writeJsonSync, writeJsonSync,
pathExistsSync, pathExistsSync,
pathExists, pathExists,
copy,
} = fse; } = fse;
return { return {
@ -46,6 +47,7 @@ const fsInjectable = getInjectable({
lstat, lstat,
rm, rm,
access, access,
copy: copy as (src: string, dest: string, options?: fse.CopyOptions) => Promise<void>,
}; };
}, },
causesSideEffects: true, causesSideEffects: true,

View File

@ -5,7 +5,10 @@
import type { DiContainer } from "@ogre-tools/injectable"; import type { DiContainer } from "@ogre-tools/injectable";
import fsInjectable from "../common/fs/fs.injectable"; import fsInjectable from "../common/fs/fs.injectable";
import { createFsFromVolume, Volume } from "memfs"; import { createFsFromVolume, Volume } from "memfs";
import type { readJsonSync as readJsonSyncImpl, writeJsonSync as writeJsonSyncImpl } from "fs-extra"; import type {
readJsonSync as readJsonSyncImpl,
writeJsonSync as writeJsonSyncImpl,
} from "fs-extra";
export const getOverrideFsWithFakes = () => { export const getOverrideFsWithFakes = () => {
const root = createFsFromVolume(Volume.fromJSON({})); const root = createFsFromVolume(Volume.fromJSON({}));
@ -46,6 +49,7 @@ export const getOverrideFsWithFakes = () => {
lstat: root.promises.lstat as any, lstat: root.promises.lstat as any,
rm: root.promises.rm, rm: root.promises.rm,
access: root.promises.access, access: root.promises.access,
copy: async (src, dest) => { throw new Error(`Tried to copy '${src}' to '${dest}'. Copying is not yet supported`); },
})); }));
}; };
}; };