Skip to content

Commit

Permalink
build(api-copy): fix issue with api-copy script on macOs platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentinTh committed Oct 27, 2023
1 parent 1cada17 commit 8cef71d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 63 deletions.
42 changes: 13 additions & 29 deletions api-copy.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
const fs = require('fs-extra');
const fs = require('node:fs');
const fse = require('fs-extra');
const path = require('path');

const recursiveCopy = (source, target) => {
if (fs.lstatSync(source).isDirectory()) {
if (!fs.existsSync(target)) {
fs.mkdirSync(target);
}

const files = fs.readdirSync(source);

files.forEach(file => {
const sourcePath = path.join(source, file);
const targetPath = path.join(target, file);
recursiveCopy(sourcePath, targetPath);
});
} else {
fs.copyFileSync(source, target);
}
};

const envBuildFile = fs.readFileSync(path.normalize('./env.build.json'));
const envBuildData = JSON.parse(envBuildFile);
const APIPath = path.normalize(envBuildData.API_PATH);
Expand All @@ -27,15 +10,16 @@ const APISourceFolder = path.join(APIPath, 'dist', 'MyoRatioAPI');
const targetFolder = 'bin/MyoRatioAPI';

if (fs.existsSync(targetFolder)) {
fs.remove(targetFolder, error => {
if (error) {
throw new Error(error);
}

recursiveCopy(APISourceFolder, targetFolder);
});
} else {
recursiveCopy(APISourceFolder, targetFolder);
fs.rmSync(targetFolder, { recursive: true, force: true });
}

console.log('--> API successfully copied to bin folder');
fse
.copy(APISourceFolder, targetFolder)
.then(() => {
console.log('--> API successfully copied to bin folder');
process.exit(0);
})
.catch(error => {
console.error(error);
process.exit(-1);
});
83 changes: 49 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"eslint-config-standard": "^17.0.0",
"eslint-plugin-json": "^3.1.0",
"eslint-plugin-prettier": "^5.0.1",
"fs-extra": "^11.1.1",
"handlebars-loader": "^1.7.3",
"html-webpack-plugin": "^5.5.1",
"innosetup-compiler": "^6.2.0",
Expand Down

0 comments on commit 8cef71d

Please sign in to comment.