1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const DEFAULT_VERSION_NAME = '1.0';
|
4 | const DEFAULT_VERSION_CODE = '1';
|
5 | function getVersionName(config) {
|
6 | return config.version ? config.version : null;
|
7 | }
|
8 | exports.getVersionName = getVersionName;
|
9 | function setVersionName(config, buildGradle, versionToReplace = DEFAULT_VERSION_NAME) {
|
10 | let versionName = getVersionName(config);
|
11 | if (versionName === null) {
|
12 | return buildGradle;
|
13 | }
|
14 | let pattern = new RegExp(`versionName "${versionToReplace}"`);
|
15 | return buildGradle.replace(pattern, `versionName "${versionName}"`);
|
16 | }
|
17 | exports.setVersionName = setVersionName;
|
18 | function getVersionCode(config) {
|
19 | return config.android && config.android.versionCode ? config.android.versionCode : null;
|
20 | }
|
21 | exports.getVersionCode = getVersionCode;
|
22 | function setVersionCode(config, buildGradle, versionCodeToReplace = DEFAULT_VERSION_CODE) {
|
23 | let versionCode = getVersionCode(config);
|
24 | if (versionCode === null) {
|
25 | return buildGradle;
|
26 | }
|
27 | let pattern = new RegExp(`versionCode ${versionCodeToReplace}`);
|
28 | return buildGradle.replace(pattern, `versionCode ${versionCode}`);
|
29 | }
|
30 | exports.setVersionCode = setVersionCode;
|
31 |
|
\ | No newline at end of file |