Skip to content

Commit acfd26a

Browse files
pan93412rileychh
andcommitted
Improve the mise.toml parser to conform to the TOML specification
Fixed #867 ("mise.toml parser fails when ruby line contains end-of-line comments") Co-authored-by: Riley Ho <riley@rileychh.dev>
1 parent 90be115 commit acfd26a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function parseRubyEngineAndVersion(rubyVersion) {
130130
console.log(`Using ${rubyVersion} as input from file .tool-versions`)
131131
} else if (rubyVersion === 'mise.toml') { // Read from mise.toml
132132
const toolVersions = fs.readFileSync('mise.toml', 'utf8').trim()
133-
const regexp = /^ruby\s*=\s*['"](.+)['"]$/
133+
const regexp = /^\s*ruby\s*=\s*['"]([^'"]+)['"](?:\s*#.*)?$/
134134
const rubyLine = toolVersions.split(/\r?\n/).filter(e => regexp.test(e))[0]
135135
rubyVersion = rubyLine.match(regexp)[1]
136136
console.log(`Using ${rubyVersion} as input from file mise.toml`)

0 commit comments

Comments
 (0)