Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
fix(init): don't overwrite base and template dockerfile if already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
rudxde committed Jul 22, 2022
1 parent 883820c commit 61fab6e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/init/src/main.ts
Expand Up @@ -65,8 +65,16 @@ async function addTemplates(args: IInitArgs): Promise<void> {
const templateDockerfileSrc = joinPath(__dirname, '../templates/Dockerfile.template');
const baseDockerfileDest = joinPath(args.workingDirectory ?? process.cwd(), args.baseDockerfileName);
const templateDockerfileDest = joinPath(args.workingDirectory ?? process.cwd(), args.templateDockerFileName);
await fsPromises.copyFile(baseDockerfileSrc, baseDockerfileDest);
await fsPromises.copyFile(templateDockerfileSrc, templateDockerfileDest);
await copyIfNotExists(baseDockerfileSrc, baseDockerfileDest);
await copyIfNotExists(templateDockerfileSrc, templateDockerfileDest);
}

async function copyIfNotExists(source: string, dest: string,): Promise<void> {
if (existsSync(dest)) {
console.log(`Skipping copy of file "${dest}", since it exists.`);
return;
}
await fsPromises.copyFile(source, dest);
}

async function addConfig(args: IInitArgs): Promise<void> {
Expand Down

0 comments on commit 61fab6e

Please sign in to comment.