-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
fix-build.js
47 lines (42 loc) · 1.2 KB
/
fix-build.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
38
39
40
41
42
43
44
45
46
47
var deps = require('../package.json');
var fs = require("fs")
var path = require("path")
async function copyDir(src,dest) {
try {
const entries = await fs.promises.readdir(src, {withFileTypes: true});
await fs.promises.mkdir(dest);
for(let entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if(entry.isDirectory()) {
await copyDir(srcPath, destPath);
} else {
await fs.promises.copyFile(srcPath, destPath);
}
}
} catch (e) {
console.log(e);
}
}
async function copyFile(src, dest) {
try {
await fs.promises.copyFile(src, dest);
} catch (e) {
}
}
async function main() {
var pluginName = deps.name.replace('@erxes', '');
await copyFile('../src/graphql/subscriptionPlugin.js', `./dist/${pluginName}/src/graphql/subscriptionPlugin.js`);
await copyDir('../src/cronjobs', `./dist/${pluginName}/src/cronjobs`);
await copyDir('../src/commands', `./dist/${pluginName}/src/commands`);
fs.rename(`./dist/${pluginName}`, './dist/main', function(err) {
if (err) {
console.log(err)
}
})
}
main()
.then(() => {
process.exit();
}).catch((e) => {
})