From 5f386b49056e794b79466bd39e9aa91c0c11776b Mon Sep 17 00:00:00 2001 From: Tomasz Misiukiewicz Date: Thu, 21 Sep 2023 09:04:57 +0200 Subject: [PATCH] try/catch require package.json --- packages/cli-platform-ios/src/tools/pods.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/cli-platform-ios/src/tools/pods.ts b/packages/cli-platform-ios/src/tools/pods.ts index 42632cbf4..cb56f1085 100644 --- a/packages/cli-platform-ios/src/tools/pods.ts +++ b/packages/cli-platform-ios/src/tools/pods.ts @@ -23,7 +23,13 @@ interface NativeDependencies { } export function getPackageJson(root: string) { - return require(path.join(root, 'package.json')); + try { + return require(path.join(root, 'package.json')); + } catch { + throw new CLIError( + 'No package.json found. Please make sure the file exists in the current folder.', + ); + } } export function getIosDependencies(dependencies: NativeDependencies) {