2018-05-11 19:43:49 +00:00
|
|
|
/** @format */
|
|
|
|
|
2017-10-18 04:19:53 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const glob = require('glob');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
module.exports = function findPodspecName(folder) {
|
2018-05-11 19:43:49 +00:00
|
|
|
const podspecs = glob.sync('*.podspec', {cwd: folder});
|
2017-10-18 04:19:53 +00:00
|
|
|
let podspecFile = null;
|
|
|
|
if (podspecs.length === 0) {
|
|
|
|
return null;
|
2018-05-11 19:43:49 +00:00
|
|
|
} else if (podspecs.length === 1) {
|
2017-10-18 04:19:53 +00:00
|
|
|
podspecFile = podspecs[0];
|
2018-05-11 19:43:49 +00:00
|
|
|
} else {
|
2017-10-18 04:19:53 +00:00
|
|
|
const folderParts = folder.split(path.sep);
|
|
|
|
const currentFolder = folderParts[folderParts.length - 1];
|
|
|
|
const toSelect = podspecs.indexOf(currentFolder + '.podspec');
|
|
|
|
if (toSelect === -1) {
|
|
|
|
podspecFile = podspecs[0];
|
2018-05-11 19:43:49 +00:00
|
|
|
} else {
|
2017-10-18 04:19:53 +00:00
|
|
|
podspecFile = podspecs[toSelect];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return podspecFile.replace('.podspec', '');
|
|
|
|
};
|