Skip to content

Commit

Permalink
fix: str.replace not a function issue (#1909)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamTrz committed Apr 21, 2023
1 parent 69c033d commit 064ad76
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions packages/cli-platform-ios/src/tools/getProjectInfo.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import {CLIError} from '@react-native-community/cli-tools';
import execa from 'execa';
import {IosProjectInfo} from '../types';

export function getProjectInfo(): IosProjectInfo {
try {
const {project} = JSON.parse(
execa.sync('xcodebuild', ['-list', '-json']).stdout,
);

const out = execa.sync('xcodebuild', ['-list', '-json']).stdout;
const {project} = JSON.parse(out);
return project;
} catch (error) {
throw new CLIError(error as any);
if (
(error as Error)?.message &&
(error as Error).message.includes('xcodebuild: error:')
) {
const match = (error as Error).message.match(/xcodebuild: error: (.*)/);
const err = match ? match[0] : error;
throw new Error(err as any);
}
throw new Error(error as any);
}
}
2 changes: 1 addition & 1 deletion packages/cli-tools/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ export class CLIError extends Error {
*/
export class UnknownProjectError extends Error {}

export const inlineString = (str: string) =>
export const inlineString = (str: string = '') =>
str.replace(/(\s{2,})/gm, ' ').trim();

0 comments on commit 064ad76

Please sign in to comment.