2018-02-09 01:10:29 +00:00
|
|
|
/**
|
2018-09-11 22:27:47 +00:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2018-02-09 01:10:29 +00:00
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2018-05-11 19:43:49 +00:00
|
|
|
*
|
|
|
|
* @format
|
2018-02-09 01:10:29 +00:00
|
|
|
*/
|
|
|
|
|
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-05-11 19:43:49 +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);
|
|
|
|
};
|
|
|
|
|
2018-05-11 19:43:49 +00:00
|
|
|
function getLinesToAddEntry(podLines, {projectName}) {
|
2017-10-18 04:19:53 +00:00
|
|
|
const linesToAddPodWithMarker = findMarkedLinesInPodfile(podLines);
|
|
|
|
if (linesToAddPodWithMarker.length > 0) {
|
|
|
|
return linesToAddPodWithMarker;
|
|
|
|
} else {
|
|
|
|
const firstTargetLined = findPodTargetLine(podLines, projectName);
|
|
|
|
return findLineToAddPod(podLines, firstTargetLined);
|
|
|
|
}
|
|
|
|
}
|