fix(react-native): fix pod install to not throw error on stderr (#17382)

This commit is contained in:
Emily Xiong 2023-06-02 17:08:19 -04:00 committed by GitHub
parent afd3cfd8c0
commit aa6b6394bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 61 deletions

View File

@ -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 = `
@ -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;
}
@ -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;
}
}

View File

@ -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 = `
@ -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;
}
}