Adding check for null ref before accessing array index (#1116)

* Adding check for null ref before accessing array index

* Adding log for missing jsCodeLocation setting
This commit is contained in:
Robert Paul
2017-12-26 00:59:28 -06:00
committed by Max
parent 0657975ba1
commit 2a051e4fe3

View File

@@ -39,7 +39,13 @@ module.exports = () => {
}
// 2. Modify jsCodeLocation value assignment
var oldJsCodeLocationAssignmentStatement = appDelegateContents.match(/(jsCodeLocation = .*)/)[1];
var jsCodeLocations = appDelegateContents.match(/(jsCodeLocation = .*)/);
var oldJsCodeLocationAssignmentStatement;
if (jsCodeLocations) {
oldJsCodeLocationAssignmentStatement = jsCodeLocations[1];
} else {
console.log('Couldn\'t find jsCodeLocation setting in AppDelegate.');
}
var newJsCodeLocationAssignmentStatement = "jsCodeLocation = [CodePush bundleURL];";
if (~appDelegateContents.indexOf(newJsCodeLocationAssignmentStatement)) {
console.log(`"jsCodeLocation" already pointing to "[CodePush bundleURL]".`);