Skip to content

Commit

Permalink
Merge pull request #155 from ably/check-directory-exist
Browse files Browse the repository at this point in the history
Add check if the directory exist
  • Loading branch information
aralovelace authored Mar 8, 2022
2 parents 2bb5f6c + 85d8117 commit d3a365a
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions scripts/setup-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,12 @@ const copyFonts = print(
log("\x1b[32m%s\x1b[0m", "No fonts directory found, skipping"); // green
return true;
}

fs.rmdirSync(rubyPath, { recursive: true });
fs.rmdirSync(npmPath, { recursive: true });
if (fs.existsSync(rubyPath)) {
fs.rmdirSync(rubyPath, {recursive: true});
}
if (fs.existsSync(npmPath)) {
fs.rmdirSync(npmPath, {recursive: true});
}

fs.mkdirSync(rubyPath);
fs.mkdirSync(npmPath);
Expand All @@ -138,9 +141,12 @@ const copyImages = print(
log("\x1b[32m%s\x1b[0m", "No images directory found, skipping"); // green
return true;
}

fs.rmdirSync(rubyPath, { recursive: true });
fs.rmdirSync(npmPath, { recursive: true });
if (fs.existsSync(rubyPath)) {
fs.rmdirSync(rubyPath, {recursive: true});
}
if (fs.existsSync(npmPath)) {
fs.rmdirSync(npmPath, {recursive: true});
}

fs.mkdirSync(rubyPath);
fs.mkdirSync(npmPath);
Expand Down Expand Up @@ -200,8 +206,9 @@ const sync = ({ verbose } = { verbose: false }) => {

modules.forEach((mod) => {
const rubyPath = rubyPathResolve(mod.directory);

fs.rmdirSync(rubyPath, { recursive: true });
if (fs.existsSync(rubyPath)) {
fs.rmdirSync(rubyPath, {recursive: true});
}
fs.mkdirSync(rubyPath);

copyRubyModuleConfig(mod);
Expand Down

0 comments on commit d3a365a

Please sign in to comment.