bugfix: Fix bug that version cannot be parsed in .tool-versions by Karibash · Pull Request #720 · ruby/setup-ruby

@Karibash

close: #719

This PR fixes a regression introduced in PR #717, where the tool fails to correctly parse the Ruby version from .tool-versions when multiple spaces exist between the tool name and version.

@Karibash

eregon

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

eregon

const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim()
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s/.test(e))[0]
rubyVersion = rubyLine.split(/\s/)[1]
rubyVersion = rubyLine.split(/\s+/)[1]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.