diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index db4a066d383fba..edac8893b3c390 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -65,7 +65,6 @@ plugins { */ project.ext.react = [ - cliPath: "$rootDir/cli.js", bundleAssetName: "RNTesterApp.android.bundle", entryFile: file("../../js/RNTesterApp.android.js"), root: "$rootDir", diff --git a/react.gradle b/react.gradle index 20c183218405ff..aee91f930a74c0 100644 --- a/react.gradle +++ b/react.gradle @@ -99,6 +99,19 @@ afterEvaluate { // Additional node and packager commandline arguments def nodeExecutableAndArgs = config.nodeExecutableAndArgs ?: ["node"] def extraPackagerArgs = config.extraPackagerArgs ?: [] + def npx = Os.isFamily(Os.FAMILY_WINDOWS) ? "npx.cmd" : "npx" + + def execCommand = [] + + if (config.cliPath || config.nodeExecutableAndArgs) { + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + execCommand.addAll(["cmd", "/c", *nodeExecutableAndArgs, cliPath]) + } else { + execCommand.addAll([*nodeExecutableAndArgs, cliPath]) + } + } else { + execCommand.addAll([npx, "react-native"]) + } def enableHermes = enableHermesForVariant(variant) @@ -140,15 +153,10 @@ afterEvaluate { extraArgs.add(bundleConfig); } - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - commandLine("cmd", "/c", *nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}", - "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, - "--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs) - } else { - commandLine(*nodeExecutableAndArgs, cliPath, bundleCommand, "--platform", "android", "--dev", "${devEnabled}", - "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, - "--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs) - } + commandLine(*execCommand, bundleCommand, "--platform", "android", "--dev", "${devEnabled}", + "--reset-cache", "--entry-file", entryFile, "--bundle-output", jsBundleFile, "--assets-dest", resourcesDir, + "--sourcemap-output", enableHermes ? jsPackagerSourceMapFile : jsOutputSourceMapFile, *extraArgs) + if (enableHermes) { doLast {