You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

mobile-center-link-scripts

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mobile-center-link-scripts - npm Package Compare versions

Comparing version

to
0.9.0

.eslintrc

10

package.json
{
"name": "mobile-center-link-scripts",
"version": "0.8.1",
"version": "0.9.0",
"description": "Node module that contains common functionality needed to link mobile-center-* modules",

@@ -28,3 +28,11 @@ "main": "src/index.js",

"xcode": "^0.8.9"
},
"devDependencies": {
"babel-eslint": "^7.2.3",
"eslint": "^4.5.0",
"eslint-plugin-react": "^7.2.1"
},
"scripts": {
"lint": "eslint ."
}
}

32

src/ios/AppDelegate.js

@@ -28,15 +28,31 @@ var fs = require('fs');

AppDelegate.prototype.addInitCode = function (code) {
AppDelegate.prototype.addInitCode = function (code, oldCodeRegExp) {
const oldCodeMatches = oldCodeRegExp ? this.appDelegateContents.match(oldCodeRegExp) : null;
if (oldCodeMatches && oldCodeMatches.length > 1) {
for (let i = 1; i < oldCodeMatches.length; i++) {
this.appDelegateContents = this.appDelegateContents.replace(oldCodeMatches[i], '');
debug(`Removed duplicate ${oldCodeRegExp} lines from AppDelegate.m`);
}
}
if (this.appDelegateContents.indexOf(code) === -1) {
const match = this.appDelegateContents.match(/NSURL \*jsCodeLocation;[ \t]*\r*\n/);
if (match === null) {
throw Error(`
/* If new code not found but old code found, replace. */
if (oldCodeMatches) {
this.appDelegateContents = this.appDelegateContents.replace(oldCodeMatches[0], code);
debug('Replaced code', code, 'to file', this.appDelegatePath);
}
else {
const match = this.appDelegateContents.match(/NSURL \*jsCodeLocation;[ \t]*\r*\n/);
if (match === null) {
throw Error(`
Could not find line "NSURL \*jsCodeLocation;" in file AppDelegate.m.
Update AppDelegate.m so that text is present, as we match on it and insert '` + code + `' after for Mobile Center SDK integration.
`);
}
const existingLine = match[0];
this.appDelegateContents = this.appDelegateContents.replace(existingLine, `${existingLine}\n${code}\n`);
debug('Added code', code, 'to file', this.appDelegatePath);
}
const existingLine = match[0];
this.appDelegateContents = this.appDelegateContents.replace(existingLine, `${existingLine}\n${code}\n`);
debug('Added code', code, 'to file', this.appDelegatePath);
} else {

@@ -43,0 +59,0 @@ debug(`Looks like ${code} is already added to AppDelegate.m`);

@@ -62,3 +62,3 @@ var fs = require('fs');

initInAppDelegate: function(header, initCode) {
initInAppDelegate: function(header, initCode, oldInitCodeRegExp) {
debug('Starting to write AppDelegate', appDelegatePath);

@@ -68,3 +68,3 @@ try {

appDelegate.addHeader(header);
appDelegate.addInitCode(initCode);
appDelegate.addInitCode(initCode, oldInitCodeRegExp);
return appDelegate.save();

@@ -71,0 +71,0 @@ } catch (e) {