Skip to content

Commit

Permalink
fix(react-native): fix pod install to not throw error on stderr (#17382)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiongemi authored Jun 2, 2023
1 parent afd3cfd commit aa6b639
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 61 deletions.
44 changes: 13 additions & 31 deletions packages/expo/src/utils/pod-install-task.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { exec } from 'child_process';
import { execSync } from 'child_process';
import { platform } from 'os';
import * as chalk from 'chalk';
import { GeneratorCallback, logger } from '@nx/devkit';
import { rmdirSync, existsSync } from 'fs-extra';
import { existsSync } from 'fs-extra';
import { join } from 'path';

const podInstallErrorMessage = `
Expand Down Expand Up @@ -32,7 +32,7 @@ export function runPodInstall(
return;
}

if (!install || existsSync(join(iosDirectory, 'Podfile'))) {
if (!install || !existsSync(join(iosDirectory, 'Podfile'))) {
logger.info('Skipping `pod install`');
return;
}
Expand All @@ -43,32 +43,14 @@ export function runPodInstall(
};
}

export function podInstall(
iosDirectory: string,
buildFolder?: string
): Promise<void> {
return new Promise((resolve, reject) => {
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')) {
resolve();
} else {
reject(new Error(podInstallErrorMessage));
}
}
);
});
export function podInstall(iosDirectory: string, buildFolder?: string) {
try {
execSync('pod install', {
cwd: iosDirectory,
stdio: 'inherit',
});
} catch (e) {
logger.error(podInstallErrorMessage);
throw e;
}
}
42 changes: 12 additions & 30 deletions packages/react-native/src/utils/pod-install-task.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { exec } from 'child_process';
import { execSync } from 'child_process';
import { platform } from 'os';
import * as chalk from 'chalk';
import { GeneratorCallback, logger } from '@nx/devkit';
import { rmdirSync, existsSync } from 'fs-extra';
import { existsSync } from 'fs-extra';
import { join } from 'path';

const podInstallErrorMessage = `
Expand Down Expand Up @@ -43,32 +43,14 @@ export function runPodInstall(
};
}

export function podInstall(
iosDirectory: string,
buildFolder?: string
): Promise<void> {
return new Promise((resolve, reject) => {
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')) {
resolve();
} else {
reject(new Error(podInstallErrorMessage));
}
}
);
});
export function podInstall(iosDirectory: string, buildFolder?: string) {
try {
execSync('pod install', {
cwd: iosDirectory,
stdio: 'inherit',
});
} catch (e) {
logger.error(podInstallErrorMessage);
throw e;
}
}

1 comment on commit aa6b639

@vercel
Copy link

@vercel vercel bot commented on aa6b639 Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.