Skip to content

Commit 2553e24

Browse files
authored
fix: ensure 'invokeLibraryCodegen' task executes 'npx' correctly on windows (#707)
@Important feel free to close it if it only fails because a local configuration is incorrect. ### Summary Fixed the error "Execution failed for task ':app:invokeLibraryCodegen'" when running yarn android in the Fabric View Library. The invokeLibraryCodegen task now correctly executes npx on all platforms by checking the OS and using cmd or sh accordingly. ### Test plan Before the fix: Run `yarn android` on example forlder and observe the build failing with the mentioned error. Apply the fix: Update the build script with the provided solution. After the fix: Run yarn android again and confirm that the build succeeds without errors.
1 parent bcccda5 commit 2553e24

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)