From bb299fd908c5e7faa843acc90e61413ec4408236 Mon Sep 17 00:00:00 2001 From: Anton Vikulov Date: Wed, 20 Sep 2023 09:36:19 +0500 Subject: [PATCH] ... --- src/utils/pluginEnvApi.ts | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/utils/pluginEnvApi.ts b/src/utils/pluginEnvApi.ts index 77c2f03a..a5d271d4 100644 --- a/src/utils/pluginEnvApi.ts +++ b/src/utils/pluginEnvApi.ts @@ -57,9 +57,6 @@ class PluginEnvApi { const to = safeRelativePath(rawTo); this.asyncActionQueue.push({type: AsyncActionType.Copy, from, to}); - if (this.cacheFile) { - this.cacheFile.addCopyFile({from, to}); - } } readFile(rawTarget: string, encoding: T) { @@ -99,9 +96,6 @@ class PluginEnvApi { const to = safeRelativePath(rawTo); this.asyncActionQueue.push({type: AsyncActionType.Write, to, data}); - if (this.cacheFile) { - this.cacheFile.addWriteFile(to, data); - } } getFileVars(rawTarget: string) { @@ -115,7 +109,9 @@ class PluginEnvApi { } executeActions() { - this.asyncActionQueue.splice(0).forEach((action) => { + const {asyncActionQueue} = this; + + asyncActionQueue.splice(0).forEach((action) => { switch (action.type) { case AsyncActionType.Copy: { const {from, to} = action; @@ -124,6 +120,9 @@ class PluginEnvApi { fs.mkdirSync(path.dirname(fullTo), {recursive: true}); fs.copyFileSync(fullFrom, fullTo); + if (this.cacheFile) { + this.cacheFile.addCopyFile({from, to}); + } break; } case AsyncActionType.Write: { @@ -132,6 +131,9 @@ class PluginEnvApi { fs.mkdirSync(path.dirname(fullTo), {recursive: true}); fs.writeFileSync(fullTo, data); + if (this.cacheFile) { + this.cacheFile.addWriteFile(to, data); + } break; } } @@ -150,6 +152,9 @@ class PluginEnvApi { await fs.promises.mkdir(path.dirname(fullTo), {recursive: true}); await fs.promises.copyFile(fullFrom, fullTo); + if (this.cacheFile) { + this.cacheFile.addCopyFile({from, to}); + } break; } case AsyncActionType.Write: { @@ -158,6 +163,9 @@ class PluginEnvApi { await fs.promises.mkdir(path.dirname(fullTo), {recursive: true}); await fs.promises.writeFile(fullTo, data); + if (this.cacheFile) { + this.cacheFile.addWriteFile(to, data); + } break; } }