File tree Expand file tree Collapse file tree 3 files changed +39
-8
lines changed Expand file tree Collapse file tree 3 files changed +39
-8
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,33 @@ jobs:
190190 if : startsWith(matrix.os, 'windows') && matrix.ruby == 'jruby'
191191 run : gem install sassc
192192
193+ testDotRubyVersion :
194+ name : " Test .ruby-version"
195+ runs-on : ubuntu-latest
196+ steps :
197+ - uses : actions/checkout@v4
198+ - run : echo "ruby-3.4.0" > .ruby-version
199+ - uses : ./
200+ - run : ruby -v | grep -F "ruby 3.4.0"
201+
202+ testToolVersions :
203+ name : " Test .tool-versions"
204+ runs-on : ubuntu-latest
205+ steps :
206+ - uses : actions/checkout@v4
207+ - run : echo "nodejs 16.0.0\nruby 3.4.0" > .tool-versions
208+ - uses : ./
209+ - run : ruby -v | grep -F "ruby 3.4.0"
210+
211+ testMise :
212+ name : " Test mise.toml"
213+ runs-on : ubuntu-latest
214+ steps :
215+ - uses : actions/checkout@v4
216+ - run : echo "[tools]\nnode = '18'\nruby = '3.4.0'" > mise.toml
217+ - uses : ./
218+ - run : ruby -v | grep -F "ruby 3.4.0"
219+
193220 testNoGemfile :
194221 name : " Test with no Gemfile"
195222 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -129,13 +129,15 @@ function parseRubyEngineAndVersion(rubyVersion) {
129129 console . log ( `Using ${ rubyVersion } as input from file .ruby-version` )
130130 } else if ( rubyVersion === '.tool-versions' ) { // Read from .tool-versions
131131 const toolVersions = fs . readFileSync ( '.tool-versions' , 'utf8' ) . trim ( )
132- const rubyLine = toolVersions . split ( / \r ? \n / ) . filter ( e => / ^ r u b y \s / . test ( e ) ) [ 0 ]
133- rubyVersion = rubyLine . split ( / \s + / ) [ 1 ]
132+ const regexp = / ^ r u b y \s + ( \S + ) /
133+ const rubyLine = toolVersions . split ( / \r ? \n / ) . filter ( e => regexp . test ( e ) ) [ 0 ]
134+ rubyVersion = rubyLine . match ( regexp ) [ 1 ]
134135 console . log ( `Using ${ rubyVersion } as input from file .tool-versions` )
135136 } else if ( rubyVersion === 'mise.toml' ) { // Read from mise.toml
136137 const toolVersions = fs . readFileSync ( 'mise.toml' , 'utf8' ) . trim ( )
137- const rubyLine = toolVersions . split ( / \r ? \n / ) . filter ( e => / ^ r u b y \s * = \s * / . test ( e ) ) [ 0 ]
138- rubyVersion = rubyLine . match ( / ^ r u b y \s * = \s * [ ' " ] ( .+ ) [ ' " ] $ / ) [ 1 ]
138+ const regexp = / ^ r u b y \s * = \s * [ ' " ] ( .+ ) [ ' " ] $ /
139+ const rubyLine = toolVersions . split ( / \r ? \n / ) . filter ( e => regexp . test ( e ) ) [ 0 ]
140+ rubyVersion = rubyLine . match ( regexp ) [ 1 ]
139141 console . log ( `Using ${ rubyVersion } as input from file mise.toml` )
140142 }
141143
You can’t perform that action at this time.
0 commit comments