Skip to content

Commit

Permalink
fix: removeSync in case of directory in copy-to-clients (#1452)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr authored Aug 19, 2020
1 parent 0a97419 commit 8a0febd
Showing 1 changed file with 2 additions and 3 deletions.
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

0 comments on commit 8a0febd

Please sign in to comment.