Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: removeSync in case of directory in copy-to-clients #1452

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions scripts/generate-clients/copy-to-clients.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
const { join } = require("path");
const { copySync, ensureDirSync } = require("fs-extra");
const { copySync, removeSync } = require("fs-extra");
const { readdirSync, lstatSync, readFileSync, existsSync, writeFileSync } = require("fs");

const getOverwritablePredicate = (packageName) => (pathName) => {
Expand Down Expand Up @@ -96,8 +96,7 @@ const copyToClients = async (sourceDir, destinationDir) => {
pinDependencies(mergedManifest);
writeFileSync(destSubPath, JSON.stringify(mergedManifest, null, 2).concat(`\n`));
} else if (overwritablePredicate(packageSub) || !existsSync(destSubPath)) {
//Overwrite the directories and files that are overwritable, or not yet exists
if (lstatSync(packageSubPath).isDirectory()) ensureDirSync(destSubPath);
if (lstatSync(packageSubPath).isDirectory()) removeSync(destSubPath);
copySync(packageSubPath, destSubPath, {
overwrite: true,
});
Expand Down