@nx/react-native
Version:
75 lines (72 loc) • 2.52 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.runPodInstall = runPodInstall;
exports.podInstall = podInstall;
const child_process_1 = require("child_process");
const node_fs_1 = require("node:fs");
const os_1 = require("os");
const path_1 = require("path");
const pc = require("picocolors");
const devkit_1 = require("@nx/devkit");
const podInstallErrorMessage = `
Running ${pc.bold('pod install')} failed, see above.
Do you have CocoaPods (https://cocoapods.org/) installed?
Check that your XCode path is correct:
${pc.bold('sudo xcode-select --print-path')}
If the path is wrong, switch the path: (your path may be different)
${pc.bold('sudo xcode-select --switch /Applications/Xcode.app')}
`;
/**
* Run pod install on ios directory
* @param iosDirectory ios directory that contains Podfile
* @returns resolve with 0 if not error, reject with error otherwise
*/
function runPodInstall(iosDirectory, install = true, options = {
buildFolder: './build',
repoUpdate: false,
deployment: false,
useBundler: false,
}) {
return () => {
if ((0, os_1.platform)() !== 'darwin') {
devkit_1.logger.info('Skipping `pod install` on non-darwin platform');
return;
}
if (!install || !(0, node_fs_1.existsSync)((0, path_1.join)(iosDirectory, 'Podfile'))) {
devkit_1.logger.info('Skipping `pod install`');
return;
}
devkit_1.logger.info(`Running \`pod install\` from "${iosDirectory}"`);
return podInstall(iosDirectory, options);
};
}
function podInstall(iosDirectory, options = {
buildFolder: './build',
repoUpdate: false,
deployment: false,
useBundler: false,
}) {
try {
if ((0, node_fs_1.existsSync)((0, path_1.join)(iosDirectory, '.xcode.env'))) {
(0, child_process_1.execSync)('touch .xcode.env', {
cwd: iosDirectory,
stdio: 'inherit',
windowsHide: false,
});
}
const podCommand = [
options.useBundler ? 'bundle exec pod install' : 'pod install',
options.repoUpdate ? '--repo-update' : '',
options.deployment ? '--deployment' : '',
].join(' ');
(0, child_process_1.execSync)(podCommand, {
cwd: iosDirectory,
stdio: 'inherit',
windowsHide: false,
});
}
catch (e) {
devkit_1.logger.error(podInstallErrorMessage);
throw e;
}
}
;