2018-02-09 01:10:29 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
|
|
|
|
2017-10-18 04:19:53 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const readPodfile = require('./readPodfile');
|
|
|
|
const findPodTargetLine = require('./findPodTargetLine');
|
|
|
|
const findLineToAddPod = require('./findLineToAddPod');
|
|
|
|
const findMarkedLinesInPodfile = require('./findMarkedLinesInPodfile');
|
|
|
|
const addPodEntry = require('./addPodEntry');
|
|
|
|
const savePodFile = require('./savePodFile');
|
|
|
|
|
2018-02-13 12:57:18 +00:00
|
|
|
module.exports = function registerNativeModulePods(name, dependencyConfig, iOSProject) {
|
2017-10-18 04:19:53 +00:00
|
|
|
const podLines = readPodfile(iOSProject.podfile);
|
|
|
|
const linesToAddEntry = getLinesToAddEntry(podLines, iOSProject);
|
2018-02-13 12:57:18 +00:00
|
|
|
addPodEntry(podLines, linesToAddEntry, dependencyConfig.podspec, name);
|
2017-10-18 04:19:53 +00:00
|
|
|
savePodFile(iOSProject.podfile, podLines);
|
|
|
|
};
|
|
|
|
|
|
|
|
function getLinesToAddEntry(podLines, { projectName }) {
|
|
|
|
const linesToAddPodWithMarker = findMarkedLinesInPodfile(podLines);
|
|
|
|
if (linesToAddPodWithMarker.length > 0) {
|
|
|
|
return linesToAddPodWithMarker;
|
|
|
|
} else {
|
|
|
|
const firstTargetLined = findPodTargetLine(podLines, projectName);
|
|
|
|
return findLineToAddPod(podLines, firstTargetLined);
|
|
|
|
}
|
|
|
|
}
|