-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathios-property-updater.js
49 lines (39 loc) · 1.41 KB
/
ios-property-updater.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
48
49
const fs = require('fs');
const path = require('path');
const findPbxFile = require('./pbx-search');
var marketingRegex = /MARKETING_VERSION = [^;]+;/g;
var projectRegex = /CURRENT_PROJECT_VERSION = [^;]+;/g;
function updateIosBuildFileProperty(shortVersion, bundleVersion) {
var filePath = findPbxFile(path.join(process.cwd(), 'ios'));
if (!fs.existsSync(filePath)) {
return;
}
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading file:', err);
return;
}
var updatedContent = data
if (shortVersion) {
updatedContent = updatedContent.replaceAll(
marketingRegex,
`MARKETING_VERSION = ${shortVersion};`
);
}
if (bundleVersion) {
updatedContent = updatedContent.replaceAll(
projectRegex,
`CURRENT_PROJECT_VERSION = ${bundleVersion};`
);
}
// Write the updated content back to the file
fs.writeFile(filePath, updatedContent, 'utf8', (err) => {
if (err) {
console.error('Error writing to file:', err);
return;
}
console.log(`File ${filePath} updated successfully - MARKETING_VERSION=${shortVersion}, PROJECT_VERSION=${bundleVersion}`);
});
});
}
module.exports = updateIosBuildFileProperty