-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetVersion.js
45 lines (38 loc) · 1.04 KB
/
setVersion.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
const fs = require('fs');
const path = require('path');
const { getWebPageCommit, getApplicationRelease } = require('./src/utils/http');
const {
encode,
promisedMkdir,
promisedAccessFile,
promisedWriteFile,
} = require('./src/utils/promisedFs');
const initializeEnv = async () => {
const commitInfo = await getWebPageCommit();
try {
await promisedAccessFile(path.join(__dirname, 'config/'));
} catch (e) {
await promisedMkdir(path.join(__dirname, 'config'));
}
if (commitInfo) {
fs.writeFileSync(
path.join(__dirname, './config/webVersion.json'),
JSON.stringify(commitInfo, null, 2),
encode
);
}
const releaseInfo = await getApplicationRelease();
if (releaseInfo) {
fs.writeFileSync(
path.join(__dirname, './config/releaseVersion.json'),
JSON.stringify(releaseInfo, null, 2),
encode
);
}
try {
await promisedAccessFile(path.join(__dirname, 'config/proxy'));
} catch (e) {
await promisedWriteFile(path.join(__dirname, 'config/proxy'), '');
}
};
initializeEnv();