Handle .tool-versions' line break on Windows (#357)

* Test .tool-version on top of Windows

* Parse .tool-version with Windows-style line endings
This commit is contained in:
Paulo F. Oliveira
2025-07-03 17:35:06 +01:00
committed by GitHub
parent 6389fe58dc
commit 1fe9179886
4 changed files with 19 additions and 7 deletions
+9 -5
View File
@@ -938,15 +938,19 @@ describe('version file', () => {
const gleamVersion = unsimulateInput('gleam-version')
it('is parsed correctly', async () => {
const erlang = '27'
const elixir = '1.17.0'
const gleam = '0.23.0'
const toolVersions = `# a comment
erlang ref:v${erlang}# comment, no space, and ref:v
const erlang = '27.3.4.1'
const elixir = '1.18.4'
const gleam = '1.9.1'
let toolVersions = `# a comment
erlang ref:v${erlang}
elixir ref:${elixir} # comment, with space and ref:
not-gleam 0.23 # not picked up
gleam ${gleam} \n`
const filename = 'test/.tool-versions'
if (process.platform === 'win32') {
// Force \r\n to test in Windows
toolVersions = toolVersions.replace(/\n/g, '\r\n')
}
fs.writeFileSync(filename, toolVersions)
process.env.GITHUB_WORKSPACE = ''
const appVersions = setupBeam.parseVersionFile(filename)