From faa6c8f2c035e2b29291d2282ac6cbf240ea4524 Mon Sep 17 00:00:00 2001 From: Noroboto Date: Mon, 2 Dec 2024 22:41:20 -0500 Subject: [PATCH] fix: Ensure 'invokeLibraryCodegen' task executes 'npx' correctly on all OS - Resolved an issue where 'invokeLibraryCodegen' failed with 'file not found' when running 'yarn android'.\n- Added OS-specific handling:\n - On Windows: Use 'cmd /c' to execute the command.\n - On other systems: Use 'sh -c' to execute the command.\n- This change ensures 'npx bob build --target codegen' runs successfully regardless of the operating system. --- .../src/exampleApp/addCodegenBuildScript.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/create-react-native-library/src/exampleApp/addCodegenBuildScript.ts b/packages/create-react-native-library/src/exampleApp/addCodegenBuildScript.ts index cf534d0a3..df61960dd 100644 --- a/packages/create-react-native-library/src/exampleApp/addCodegenBuildScript.ts +++ b/packages/create-react-native-library/src/exampleApp/addCodegenBuildScript.ts @@ -10,8 +10,14 @@ def isNewArchitectureEnabled() { if (isNewArchitectureEnabled()) { // Since our library doesn't invoke codegen automatically we need to do it here. tasks.register('invokeLibraryCodegen', Exec) { - workingDir "$rootDir/../../" - commandLine "npx", "bob", "build", "--target", "codegen" + workingDir "$rootDir/../../" + def isWindows = System.getProperty('os.name').toLowerCase().contains('windows') + + if (isWindows) { + commandLine 'cmd', '/c', 'npx bob build --target codegen' + } else { + commandLine 'sh', '-c', 'npx bob build --target codegen' + } } preBuild.dependsOn invokeLibraryCodegen }`;