From 06f4802748ee9c207fe54d87679ce82812d3ca38 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Fri, 2 Dec 2022 16:18:15 -0500 Subject: [PATCH] Fix type error Signed-off-by: Sebastian Malton --- src/common/fs/write-file.injectable.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/fs/write-file.injectable.ts b/src/common/fs/write-file.injectable.ts index faa5285ca1..75e07775e3 100644 --- a/src/common/fs/write-file.injectable.ts +++ b/src/common/fs/write-file.injectable.ts @@ -16,15 +16,17 @@ const writeFileInjectable = getInjectable({ const { writeFile, ensureDir } = di.inject(fsInjectable); const getDirnameOfPath = di.inject(getDirnameOfPathInjectable); - return async (filePath, content, opts) => { + return async (filePath, content, opts = {}) => { await ensureDir(getDirnameOfPath(filePath), { mode: 0o755, - ...(opts ?? {}), + ...opts, }); + const { encoding = "utf-8", ...options } = opts; + await writeFile(filePath, content, { - encoding: "utf-8", - ...(opts ?? {}), + encoding: encoding as BufferEncoding, + ...options, }); }; },