Skip to content

Commit

Permalink
fix(react-native): log errors for pod install (#16386)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi authored Apr 19, 2023
1 parent 0fc3d44 commit 16e115f
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions packages/react-native/src/utils/pod-install-task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { execSync } from 'child_process';
import { exec } from 'child_process';
import { platform } from 'os';
import * as chalk from 'chalk';
import { GeneratorCallback, logger } from '@nx/devkit';
Expand Down Expand Up @@ -48,21 +48,34 @@ export function podInstall(
buildFolder?: string
): Promise<void> {
return new Promise((resolve, reject) => {
const result = execSync('pod install', {
cwd: iosDirectory,
});
logger.info(result.toString());
if (result.toString().includes('Pod installation complete')) {
// Remove build folder after pod install
if (buildFolder) {
buildFolder = join(iosDirectory, buildFolder);
if (existsSync(buildFolder)) {
rmdirSync(buildFolder, { recursive: true });
exec(
'pod install',
{
cwd: iosDirectory,
},
(error, stdout, stderr) => {
if (error) {
logger.error(error.message);
reject(new Error(podInstallErrorMessage));
}
if (stderr) {
logger.error(stderr);
reject(new Error(podInstallErrorMessage));
}
logger.info(stdout);
if (stdout.includes('Pod installation complete')) {
// Remove build folder after pod install
if (buildFolder) {
buildFolder = join(iosDirectory, buildFolder);
if (existsSync(buildFolder)) {
rmdirSync(buildFolder, { recursive: true });
}
}
resolve();
} else {
reject(new Error(podInstallErrorMessage));
}
}
resolve();
} else {
reject(new Error(podInstallErrorMessage));
}
);
});
}

0 comments on commit 16e115f

Please sign in to comment.