Skip to content

Commit

Permalink
fix: 修复基础模版文件未创建完成时就执行 git 命令的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassama committed Mar 12, 2022
1 parent f058986 commit b30997b
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,13 @@ export const filepath = {
data: string | NodeJS.ArrayBufferView,
options: { overwrite: boolean },
) {
if (options.overwrite) {
fs.writeFileSync(file, data, 'utf-8');
} else {
fs.access(file, fs.constants.F_OK, (err) => {
if (err) {
fs.writeFileSync(file, data, 'utf-8');
}
});
if (!options.overwrite) {
try {
fs.accessSync(file, fs.constants.F_OK);
return;
} catch (err) {}
}
await fs.writeFileSync(file, data, 'utf-8');
},
copyFile: async function (
targetFile: string,
Expand All @@ -98,13 +96,15 @@ export const filepath = {
);
} else {
await this.recursionMkdir(targetFile);
fs.readdirSync(sourceFile, 'utf8').forEach((filePath: string) => {
this.copyFile(
path.join(targetFile, filePath),
path.join(sourceFile, filePath),
options,
);
});
await Promise.all(
fs.readdirSync(sourceFile, 'utf8').map(async (filePath: string) => {
await this.copyFile(
path.join(targetFile, filePath),
path.join(sourceFile, filePath),
options,
);
}),
);
}
},
};
Expand Down

0 comments on commit b30997b

Please sign in to comment.