react-native-integrate
Version:
Automate integration of additional code into React Native projects
35 lines (34 loc) • 1.5 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIosProjectPath = getIosProjectPath;
exports.getIosProjectName = getIosProjectName;
exports.getPbxProjectPath = getPbxProjectPath;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const constants_1 = require("../constants");
const getProjectPath_1 = require("./getProjectPath");
function getIosProjectPath(projectPath = (0, getProjectPath_1.getProjectPath)()) {
const projectName = getIosProjectName(projectPath);
return path_1.default.join(projectPath, 'ios', projectName);
}
function getIosProjectName(projectPath = (0, getProjectPath_1.getProjectPath)()) {
let xcodeProjFolder;
try {
xcodeProjFolder = fs_1.default
.readdirSync(path_1.default.join(projectPath, 'ios'))
.find(x => x.endsWith(constants_1.Constants.XCODEPROJ_EXT));
}
catch (_e) {
xcodeProjFolder = undefined;
}
if (!xcodeProjFolder)
throw new Error('iOS project not found.');
return xcodeProjFolder.replace(constants_1.Constants.XCODEPROJ_EXT, '');
}
function getPbxProjectPath(projectPath = (0, getProjectPath_1.getProjectPath)()) {
const iosProjectPath = getIosProjectPath(projectPath);
return path_1.default.join(iosProjectPath + '.xcodeproj', 'project.pbxproj');
}