Skip to content

Commit d5da70e

Browse files
danilobuergerfacebook-github-bot
authored andcommitted
Replaced windowsAwareYarn with windowsAwareCommandLine for node calls (#33530)
Summary: It is not necessary to call node via yarn. Instead with this commit node is called directly (windows aware). This enables builds on systems that don't have yarn installed. Fixes #33525 ## Changelog [Android] [Fixed] - Don't require yarn for codegen tasks Pull Request resolved: #33530 Test Plan: 1. react-native init test 2. cd test 3. enable newArchEnabled=true (gradle.properties) 4. enable enableHermes: true (build.gradle) 5. react-native run-android (when the yarn is not installed on the system) (I have not tested or verified if this works on windows build machines) Reviewed By: sshic Differential Revision: D35279376 Pulled By: cortinico fbshipit-source-id: 430e4a7bcdec7d5377efac747f6b935d634451cc
1 parent 44de392 commit d5da70e

File tree

4 files changed

+4
-29
lines changed

4 files changed

+4
-29
lines changed

packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTask.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
package com.facebook.react.tasks
99

1010
import com.facebook.react.codegen.generator.JavaGenerator
11-
import com.facebook.react.utils.windowsAwareYarn
11+
import com.facebook.react.utils.windowsAwareCommandLine
1212
import org.gradle.api.GradleException
1313
import org.gradle.api.file.Directory
1414
import org.gradle.api.file.DirectoryProperty
@@ -93,7 +93,7 @@ abstract class GenerateCodegenArtifactsTask : Exec() {
9393

9494
internal fun setupCommandLine() {
9595
commandLine(
96-
windowsAwareYarn(
96+
windowsAwareCommandLine(
9797
*nodeExecutableAndArgs.get().toTypedArray(),
9898
reactNativeDir.file("scripts/generate-specs-cli.js").get().asFile.absolutePath,
9999
"--platform",

packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package com.facebook.react.tasks
99

10-
import com.facebook.react.utils.windowsAwareYarn
10+
import com.facebook.react.utils.windowsAwareCommandLine
1111
import org.gradle.api.file.DirectoryProperty
1212
import org.gradle.api.file.RegularFile
1313
import org.gradle.api.provider.ListProperty
@@ -49,7 +49,7 @@ abstract class GenerateCodegenSchemaTask : Exec() {
4949

5050
internal fun setupCommandLine() {
5151
commandLine(
52-
windowsAwareYarn(
52+
windowsAwareCommandLine(
5353
*nodeExecutableAndArgs.get().toTypedArray(),
5454
codegenDir
5555
.file("lib/cli/combine/combine-js-to-schema-cli.js")

packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/TaskUtils.kt

-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@ internal fun windowsAwareCommandLine(vararg args: Any): List<Any> =
1414
args.toList()
1515
}
1616

17-
internal fun windowsAwareYarn(vararg args: Any): List<Any> =
18-
if (Os.isWindows()) {
19-
listOf("yarn.cmd") + args
20-
} else {
21-
listOf("yarn") + args
22-
}
23-
2417
internal fun windowsAwareBashCommandLine(
2518
vararg args: String,
2619
bashWindowsHome: String? = null

packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/TaskUtilsTest.kt

-18
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,6 @@ class TaskUtilsTest {
4242
assertEquals(listOf("cmd", "/c", "a", "b", "c"), windowsAwareCommandLine("a", "b", "c"))
4343
}
4444

45-
@Test
46-
@WithOs(OS.MAC)
47-
fun windowsAwareYarn_onMac_returnsTheList() {
48-
assertEquals(listOf("yarn", "a", "b", "c"), windowsAwareYarn("a", "b", "c"))
49-
}
50-
51-
@Test
52-
@WithOs(OS.UNIX)
53-
fun windowsAwareYarn_onLinux_returnsTheList() {
54-
assertEquals(listOf("yarn", "a", "b", "c"), windowsAwareYarn("a", "b", "c"))
55-
}
56-
57-
@Test
58-
@WithOs(OS.WIN)
59-
fun windowsAwareYarn_onWindows_prependsCmd() {
60-
assertEquals(listOf("yarn.cmd", "a", "b", "c"), windowsAwareYarn("a", "b", "c"))
61-
}
62-
6345
@Test
6446
@WithOs(OS.MAC)
6547
fun windowsAwareBashCommandLine_onMac_returnsTheList() {

0 commit comments

Comments
 (0)