From 2a9b8364291ea757fd5be46ea0df6d1b93818347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Fri, 19 Sep 2025 20:31:29 +0200 Subject: [PATCH] Assert the existence of CMakeList.txt before passing control to CMake --- .changeset/social-rivers-tie.md | 5 +++++ packages/cmake-rn/src/cli.ts | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 .changeset/social-rivers-tie.md diff --git a/.changeset/social-rivers-tie.md b/.changeset/social-rivers-tie.md new file mode 100644 index 00000000..6748eb41 --- /dev/null +++ b/.changeset/social-rivers-tie.md @@ -0,0 +1,5 @@ +--- +"cmake-rn": patch +--- + +Assert the existence of CMakeList.txt before passing control to CMake diff --git a/packages/cmake-rn/src/cli.ts b/packages/cmake-rn/src/cli.ts index 477f5feb..d3f2e066 100644 --- a/packages/cmake-rn/src/cli.ts +++ b/packages/cmake-rn/src/cli.ts @@ -9,6 +9,7 @@ import { Option, spawn, oraPromise, + assertFixable, } from "@react-native-node-api/cli-utils"; import { isSupportedTriplet } from "react-native-node-api"; @@ -131,6 +132,14 @@ for (const platform of platforms) { program = program.action( async ({ target: requestedTargets, ...baseOptions }) => { + assertFixable( + fs.existsSync(path.join(baseOptions.source, "CMakeLists.txt")), + `No CMakeLists.txt found in source directory: ${chalk.dim(baseOptions.source)}`, + { + instructions: `Change working directory into a directory with a CMakeLists.txt, create one or specify the correct source directory using --source`, + }, + ); + const buildPath = getBuildPath(baseOptions); if (baseOptions.clean) { await fs.promises.rm(buildPath, { recursive: true, force: true });