From af48b7de5f416c793238307458b993933374cfb6 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 2 Dec 2022 16:10:59 -0500 Subject: [PATCH] Handle copy as part of fake FS Signed-off-by: Sebastian Malton --- src/common/fs/fs.injectable.ts | 2 ++ src/test-utils/override-fs-with-fakes.ts | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/fs/fs.injectable.ts b/src/common/fs/fs.injectable.ts index 74c3050936..05ea3b2032 100644 --- a/src/common/fs/fs.injectable.ts +++ b/src/common/fs/fs.injectable.ts @@ -29,6 +29,7 @@ const fsInjectable = getInjectable({ writeJsonSync, pathExistsSync, pathExists, + copy, } = fse; return { @@ -46,6 +47,7 @@ const fsInjectable = getInjectable({ lstat, rm, access, + copy: copy as (src: string, dest: string, options?: fse.CopyOptions) => Promise, }; }, causesSideEffects: true, diff --git a/src/test-utils/override-fs-with-fakes.ts b/src/test-utils/override-fs-with-fakes.ts index f259d0ac92..a144e99d97 100644 --- a/src/test-utils/override-fs-with-fakes.ts +++ b/src/test-utils/override-fs-with-fakes.ts @@ -5,7 +5,10 @@ import type { DiContainer } from "@ogre-tools/injectable"; import fsInjectable from "../common/fs/fs.injectable"; 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 = () => { const root = createFsFromVolume(Volume.fromJSON({})); @@ -46,6 +49,7 @@ export const getOverrideFsWithFakes = () => { lstat: root.promises.lstat as any, rm: root.promises.rm, access: root.promises.access, + copy: async (src, dest) => { throw new Error(`Tried to copy '${src}' to '${dest}'. Copying is not yet supported`); }, })); }; };