Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package com.facebook.react.tasks

import com.facebook.react.codegen.generator.JavaGenerator
import com.facebook.react.utils.windowsAwareYarn
import com.facebook.react.utils.windowsAwareCommandLine
import org.gradle.api.GradleException
import org.gradle.api.file.Directory
import org.gradle.api.file.DirectoryProperty
Expand Down Expand Up @@ -93,7 +93,7 @@ abstract class GenerateCodegenArtifactsTask : Exec() {

internal fun setupCommandLine() {
commandLine(
windowsAwareYarn(
windowsAwareCommandLine(
*nodeExecutableAndArgs.get().toTypedArray(),
reactNativeDir.file("scripts/generate-specs-cli.js").get().asFile.absolutePath,
"--platform",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

package com.facebook.react.tasks

import com.facebook.react.utils.windowsAwareYarn
import com.facebook.react.utils.windowsAwareCommandLine
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFile
import org.gradle.api.provider.ListProperty
Expand Down Expand Up @@ -49,7 +49,7 @@ abstract class GenerateCodegenSchemaTask : Exec() {

internal fun setupCommandLine() {
commandLine(
windowsAwareYarn(
windowsAwareCommandLine(
*nodeExecutableAndArgs.get().toTypedArray(),
codegenDir
.file("lib/cli/combine/combine-js-to-schema-cli.js")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@ internal fun windowsAwareCommandLine(vararg args: Any): List<Any> =
args.toList()
}

internal fun windowsAwareYarn(vararg args: Any): List<Any> =
if (Os.isWindows()) {
listOf("yarn.cmd") + args
} else {
listOf("yarn") + args
}

internal fun windowsAwareBashCommandLine(
vararg args: String,
bashWindowsHome: String? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,6 @@ class TaskUtilsTest {
assertEquals(listOf("cmd", "/c", "a", "b", "c"), windowsAwareCommandLine("a", "b", "c"))
}

@Test
@WithOs(OS.MAC)
fun windowsAwareYarn_onMac_returnsTheList() {
assertEquals(listOf("yarn", "a", "b", "c"), windowsAwareYarn("a", "b", "c"))
}

@Test
@WithOs(OS.UNIX)
fun windowsAwareYarn_onLinux_returnsTheList() {
assertEquals(listOf("yarn", "a", "b", "c"), windowsAwareYarn("a", "b", "c"))
}

@Test
@WithOs(OS.WIN)
fun windowsAwareYarn_onWindows_prependsCmd() {
assertEquals(listOf("yarn.cmd", "a", "b", "c"), windowsAwareYarn("a", "b", "c"))
}

@Test
@WithOs(OS.MAC)
fun windowsAwareBashCommandLine_onMac_returnsTheList() {
Expand Down