Skip to content

Commit 1ed2242

Browse files
committed
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.
1 parent e969c89 commit 1ed2242

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/create-react-native-library/src/exampleApp/addCodegenBuildScript.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ def isNewArchitectureEnabled() {
1010
if (isNewArchitectureEnabled()) {
1111
// Since our library doesn't invoke codegen automatically we need to do it here.
1212
tasks.register('invokeLibraryCodegen', Exec) {
13-
workingDir "$rootDir/../../"
14-
commandLine "npx", "bob", "build", "--target", "codegen"
13+
workingDir "$rootDir/../../"
14+
def isWindows = System.getProperty('os.name').toLowerCase().contains('windows')
15+
16+
if (isWindows) {
17+
commandLine 'cmd', '/c', 'npx bob build --target codegen'
18+
} else {
19+
commandLine 'sh', '-c', 'npx bob build --target codegen'
20+
}
1521
}
1622
preBuild.dependsOn invokeLibraryCodegen
1723
}`;

0 commit comments

Comments
 (0)