-
Notifications
You must be signed in to change notification settings - Fork 62
/
fix-script.js
42 lines (32 loc) · 1.3 KB
/
fix-script.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
const path = require('path');
const utilities = require('./utilities');
function updateProject (project) {
console.log(path.dirname(path.relative(process.cwd(), project.filepath)));
const section = project.hash.project.objects.PBXShellScriptBuildPhase;
for (const key of Object.keys(section)) {
// Look for the React native script.
const step = section[key];
if (step && step.shellScript && step.shellScript.indexOf('react-native-xcode.sh') >= 0) {
// Found it!
// Need to add our actual mappings to the project.
const configurations = utilities.getMappings().join('|');
const newScript = `"export NODE_BINARY=node\\nexport DEVELOPMENT_BUILD_CONFIGURATIONS=\\"${configurations}|Debug\\"\\n../node_modules/react-native-schemes-manager/lib/react-native-xcode.sh"`;
if (step.shellScript === newScript) {
// It's already up to date.
console.log(' - [skipped] already done');
return false;
} else {
step.shellScript = newScript;
console.log(` ✔ [fixed]`);
return true;
}
}
}
}
module.exports = function findAndFix () {
// Find all of the pbxproj files we care about.
const pattern = './ios/*.xcodeproj/project.pbxproj';
utilities.updateProjectsMatchingGlob(pattern, (err, project) => {
return updateProject(project);
});
};