Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
Feverqwe committed Sep 20, 2023
1 parent c37411e commit 3e97b22
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/utils/pluginEnvApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends BufferEncoding>(rawTarget: string, encoding: T) {
Expand Down Expand Up @@ -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) {
Expand All @@ -124,6 +118,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: {
Expand All @@ -132,6 +129,9 @@ class PluginEnvApi {

fs.mkdirSync(path.dirname(fullTo), {recursive: true});
fs.writeFileSync(fullTo, data);
if (this.cacheFile) {
this.cacheFile.addWriteFile(to, data);
}
break;
}
}
Expand All @@ -150,6 +150,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: {
Expand All @@ -158,6 +161,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;
}
}
Expand Down

0 comments on commit 3e97b22

Please sign in to comment.