-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversion-android.js
More file actions
37 lines (34 loc) · 958 Bytes
/
version-android.js
File metadata and controls
37 lines (34 loc) · 958 Bytes
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 fs = require('fs');
const sh = require('shelljs');
const replace = require('replace-in-file');
module.exports = ((params) => {
const version = params.version;
const noGit = params.noGit;
const androidConfig = params.androidConfig;
if (fs.existsSync(androidConfig)) {
replace.sync({
files: androidConfig,
from: /versionName\s+.*/,
to: `versionName "${version}"`,
});
let versionCode = 0;
const versionParts = version.split('.');
if (versionParts[0]) {
versionCode += parseInt(versionParts[0], 10) * 10000, 10;
}
if (versionParts[1]) {
versionCode += parseInt(versionParts[1], 10) * 100, 10;
}
if (versionParts[2]) {
versionCode += parseInt(versionParts[2], 10);
}
replace.sync({
files: androidConfig,
from: /versionCode\s+.*/,
to: `versionCode ${versionCode}`,
});
if (!noGit) {
sh.exec(`git add ${androidConfig}`);
}
}
});