-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-copy.js
37 lines (32 loc) · 919 Bytes
/
api-copy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { readFileSync, existsSync, rmSync } = require('node:fs');
const fse = require('fs-extra');
const path = require('node:path');
let envBuildFile;
try {
envBuildFile = readFileSync(path.normalize('./env.build.json'), { encoding: 'utf8' });
} catch (error) {
console.error(error);
process.exit(-1);
}
const envBuildData = JSON.parse(envBuildFile);
const APIPath = path.normalize(envBuildData.API_PATH);
const APISourceFolder = path.join(APIPath, 'dist', 'MyoRatioAPI');
const targetFolder = 'bin/MyoRatioAPI';
if (existsSync(targetFolder)) {
try {
rmSync(targetFolder, { recursive: true, force: true });
} catch (error) {
console.error(error);
process.exit(-1);
}
}
fse
.copy(APISourceFolder, targetFolder)
.then(() => {
console.log('--> API successfully copied to bin folder');
process.exit(0);
})
.catch(error => {
console.error(error);
process.exit(-1);
});