Skip to content

Commit ac03cb7

Browse files
committed
Use .test() instead of .match() where possible
1 parent 5e4f0a1 commit ac03cb7

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

bundler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
7474
if (engine === 'ruby' && common.floatVersion(rubyVersion) <= 2.2) {
7575
console.log('Bundler 2 requires Ruby 2.3+, using Bundler 1 on Ruby <= 2.2')
7676
bundlerVersion = '1'
77-
} else if (engine === 'ruby' && rubyVersion.match(/^2\.3\.[01]/)) {
77+
} else if (engine === 'ruby' && /^2\.3\.[01]/.test(rubyVersion)) {
7878
console.log('Ruby 2.3.0 and 2.3.1 have shipped with an old rubygems that only works with Bundler 1')
7979
bundlerVersion = '1'
8080
} else if (engine === 'jruby' && rubyVersion.startsWith('9.1')) { // JRuby 9.1 targets Ruby 2.3, treat it the same
@@ -90,7 +90,7 @@ export async function installBundler(bundlerVersionInput, lockFile, platform, ru
9090
console.log(`Using Bundler 1 shipped with ${engine}-${rubyVersion}`)
9191
} else {
9292
const gem = path.join(rubyPrefix, 'bin', 'gem')
93-
const bundlerVersionConstraint = bundlerVersion.match(/^\d+\.\d+\.\d+/) ? bundlerVersion : `~> ${bundlerVersion}`
93+
const bundlerVersionConstraint = /^\d+\.\d+\.\d+/.test(bundlerVersion) ? bundlerVersion : `~> ${bundlerVersion}`
9494
await exec.exec(gem, ['install', 'bundler', '-v', bundlerVersionConstraint])
9595
}
9696

dist/index.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ function parseRubyEngineAndVersion(rubyVersion) {
9191
console.log(`Using ${rubyVersion} as input from file .ruby-version`)
9292
} else if (rubyVersion === '.tool-versions') { // Read from .tool-versions
9393
const toolVersions = fs.readFileSync('.tool-versions', 'utf8').trim()
94-
const rubyLine = toolVersions.split(/\r?\n/).filter(e => e.match(/^ruby\s/))[0]
94+
const rubyLine = toolVersions.split(/\r?\n/).filter(e => /^ruby\s/.test(e))[0]
9595
rubyVersion = rubyLine.match(/^ruby\s+(.+)$/)[1]
9696
console.log(`Using ${rubyVersion} as input from file .tool-versions`)
9797
}
9898

9999
let engine, version
100-
if (rubyVersion.match(/^(\d+)/) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z
100+
if (/^(\d+)/.test(rubyVersion) || common.isHeadVersion(rubyVersion)) { // X.Y.Z => ruby-X.Y.Z
101101
engine = 'ruby'
102102
version = rubyVersion
103103
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion

windows.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export function addVCVARSEnv() {
134134
let newEnv = new Map()
135135
let cmd = `cmd.exe /c "${vcVars} && set"`
136136
let newSet = cp.execSync(cmd).toString().trim().split(/\r?\n/)
137-
newSet = newSet.filter(line => line.match(/\S=\S/))
137+
newSet = newSet.filter(line => /\S=\S/.test(line))
138138
newSet.forEach(s => {
139139
let [k,v] = common.partition(s, '=')
140140
newEnv.set(k,v)

0 commit comments

Comments
 (0)