Skip to content

Commit 2b0eda2

Browse files
committed
Always use downloaded Yarn as per documentation #284
1 parent 0b81b10 commit 2b0eda2

File tree

6 files changed

+13
-21
lines changed

6 files changed

+13
-21
lines changed

.github/workflows/build-examples.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ jobs:
1515
uses: actions/setup-node@v3
1616
with:
1717
node-version: 18
18-
- name: Install yarn
19-
run: npm install -g yarn@1.22.17
2018
- name: Gradle Version
2119
run: ./gradlew --version
2220
- name: Build Node.js Scripts Project

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ jobs:
2222
uses: actions/setup-node@v3
2323
with:
2424
node-version: 18
25-
- name: Install yarn
26-
run: npm install -g yarn@1.22.17
2725
- name: Setup Gradle
2826
uses: gradle/gradle-build-action@v2
2927
with:

.github/workflows/publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
uses: actions/setup-node@v3
2121
with:
2222
node-version: 18
23-
- name: Install yarn
24-
run: npm install -g yarn@1.22.17
2523
- name: Build
2624
run: ./gradlew build
2725
- name: Publish

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Version 6.x *(unreleased)*
44
* Upgrade default Node to 18.17.1 and npm to 9.6.7
5+
* Always use downloaded Yarn as per documentation [#284](https://github.com/node-gradle/gradle-node-plugin/issues/284)
56

67
## Version 6.0.0 *(2023-08-15)*
78
* Removed deprecated `nodeModulesDir` from `NodeExtension`

src/main/kotlin/com/github/gradle/node/variant/VariantComputer.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,13 @@ open class VariantComputer {
153153
fun computeYarnBinDir(yarnDirProvider: Provider<Directory>, platform: Property<Platform>) = computeProductBinDir(yarnDirProvider, platform)
154154

155155
fun computeYarnExec(nodeExtension: NodeExtension, yarnBinDirProvider: Provider<Directory>): Provider<String> {
156-
return zip(nodeExtension.yarnCommand, nodeExtension.download, yarnBinDirProvider).map {
157-
val (yarnCommand, download, yarnBinDir) = it
156+
return zip(nodeExtension.yarnCommand, yarnBinDirProvider).map {
157+
val (yarnCommand, yarnBinDir) = it
158158
val command = if (nodeExtension.resolvedPlatform.get().isWindows()) {
159159
yarnCommand.mapIf({ it == "yarn" }) { "yarn.cmd" }
160160
} else yarnCommand
161-
if (download) yarnBinDir.dir(command).asFile.absolutePath else command
161+
// This is conceptually pretty simple as we per documentation always download yarn
162+
yarnBinDir.dir(command).asFile.absolutePath
162163
}
163164
}
164165

src/main/kotlin/com/github/gradle/node/yarn/exec/YarnExecRunner.kt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,13 @@ abstract class YarnExecRunner {
5858
yarnBinDirProvider: Provider<Directory>,
5959
variantComputer: VariantComputer
6060
): Provider<List<String>> {
61-
return nodeExtension.download.flatMap { download ->
62-
if (!download) {
63-
providers.provider { listOf<String>() }
64-
}
65-
val nodeBinDirProvider = variantComputer.computeNodeBinDir(nodeDirProvider, nodeExtension.resolvedPlatform)
66-
val npmDirProvider = variantComputer.computeNpmDir(nodeExtension, nodeDirProvider)
67-
val npmBinDirProvider = variantComputer.computeNpmBinDir(npmDirProvider, nodeExtension.resolvedPlatform)
68-
zip(nodeBinDirProvider, npmBinDirProvider, yarnBinDirProvider)
69-
.map { (nodeBinDir, npmBinDir, yarnBinDir) ->
70-
listOf(yarnBinDir, npmBinDir, nodeBinDir).map { file -> file.asFile.absolutePath }
71-
}
72-
}
61+
// This is conceptually pretty simple as we per documentation always download yarn
62+
val nodeBinDirProvider = variantComputer.computeNodeBinDir(nodeDirProvider, nodeExtension.resolvedPlatform)
63+
val npmDirProvider = variantComputer.computeNpmDir(nodeExtension, nodeDirProvider)
64+
val npmBinDirProvider = variantComputer.computeNpmBinDir(npmDirProvider, nodeExtension.resolvedPlatform)
65+
return zip(nodeBinDirProvider, npmBinDirProvider, yarnBinDirProvider)
66+
.map { (nodeBinDir, npmBinDir, yarnBinDir) ->
67+
listOf(yarnBinDir, npmBinDir, nodeBinDir).map { file -> file.asFile.absolutePath }
68+
}
7369
}
7470
}

0 commit comments

Comments
 (0)