Skip to content

Commit

Permalink
chore(node): Move a function out of Yarn2Test
Browse files Browse the repository at this point in the history
Prepare for reducing indentation of the tests.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Dec 12, 2024
1 parent 958f871 commit ee6016c
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions plugins/package-managers/node/src/test/kotlin/yarn2/Yarn2Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,23 @@ class Yarn2Test : WordSpec() {
}
}
}
}

/**
* Check whether an executable defined in a `.yarnrc.yml` file is used when invoked with the given [workingDir]
* and [config]. This should be the case when Corepack is not enabled.
*/
private fun checkExecutableFromYarnRc(workingDir: File, config: AnalyzerConfiguration = AnalyzerConfiguration()) {
val executable = "yarn-wrapper.js"
workingDir.resolve(".yarnrc.yml").writeText("yarnPath: $executable")
val executableFile = workingDir.resolve(executable).apply {
writeText("#!/usr/bin/env node\nconsole.log('yarn')")
}
/**
* Check whether an executable defined in a `.yarnrc.yml` file is used when invoked with the given [workingDir]
* and [config]. This should be the case when Corepack is not enabled.
*/
private fun checkExecutableFromYarnRc(workingDir: File, config: AnalyzerConfiguration = AnalyzerConfiguration()) {
val executable = "yarn-wrapper.js"
workingDir.resolve(".yarnrc.yml").writeText("yarnPath: $executable")
val executableFile = workingDir.resolve(executable).apply {
writeText("#!/usr/bin/env node\nconsole.log('yarn')")
}

val yarn = Yarn2("Yarn2", workingDir, config, RepositoryConfiguration())
val command = yarn.command(workingDir)
val yarn = Yarn2("Yarn2", workingDir, config, RepositoryConfiguration())
val command = yarn.command(workingDir)

command shouldBe executableFile.absolutePath
}
command shouldBe executableFile.absolutePath
}

/**
Expand Down

0 comments on commit ee6016c

Please sign in to comment.