react-native/local-cli/core/ios/findPodspecName.js
Eli White aba4ec0c09 Prettier RN local-cli
Reviewed By: yungsters

Differential Revision: D7962462

fbshipit-source-id: 0afe2092af8703895de91a6d1400315c3173aa6d
2018-05-11 13:00:50 -07:00

28 lines
707 B
JavaScript

/** @format */
'use strict';
const glob = require('glob');
const path = require('path');
module.exports = function findPodspecName(folder) {
const podspecs = glob.sync('*.podspec', {cwd: folder});
let podspecFile = null;
if (podspecs.length === 0) {
return null;
} else if (podspecs.length === 1) {
podspecFile = podspecs[0];
} else {
const folderParts = folder.split(path.sep);
const currentFolder = folderParts[folderParts.length - 1];
const toSelect = podspecs.indexOf(currentFolder + '.podspec');
if (toSelect === -1) {
podspecFile = podspecs[0];
} else {
podspecFile = podspecs[toSelect];
}
}
return podspecFile.replace('.podspec', '');
};