From 6ff1e3ca027a2806e1759d83ee3a0d883ea63ff9 Mon Sep 17 00:00:00 2001 From: Yi-Jyun Pan Date: Fri, 30 Jan 2026 22:05:05 +0800 Subject: [PATCH] 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 --- dist/index.js | 2 +- index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 801b222ca..74b51ee70 100644 --- a/dist/index.js +++ b/dist/index.js @@ -92559,7 +92559,7 @@ function parseRubyEngineAndVersion(rubyVersion) { console.log(`Using ${rubyVersion} as input from file .tool-versions`) } else if (rubyVersion === 'mise.toml') { // Read from mise.toml const toolVersions = fs.readFileSync('mise.toml', 'utf8').trim() - const regexp = /^ruby\s*=\s*['"](.+)['"]$/ + const regexp = /^\s*ruby\s*=\s*['"]([^'"]+)['"]\s*(?:#.*)?$/ const rubyLine = toolVersions.split(/\r?\n/).filter(e => regexp.test(e))[0] rubyVersion = rubyLine.match(regexp)[1] console.log(`Using ${rubyVersion} as input from file mise.toml`) diff --git a/index.js b/index.js index 29c753d1e..7fdcf5b3e 100644 --- a/index.js +++ b/index.js @@ -130,7 +130,7 @@ function parseRubyEngineAndVersion(rubyVersion) { console.log(`Using ${rubyVersion} as input from file .tool-versions`) } else if (rubyVersion === 'mise.toml') { // Read from mise.toml const toolVersions = fs.readFileSync('mise.toml', 'utf8').trim() - const regexp = /^ruby\s*=\s*['"](.+)['"]$/ + const regexp = /^\s*ruby\s*=\s*['"]([^'"]+)['"]\s*(?:#.*)?$/ const rubyLine = toolVersions.split(/\r?\n/).filter(e => regexp.test(e))[0] rubyVersion = rubyLine.match(regexp)[1] console.log(`Using ${rubyVersion} as input from file mise.toml`)