From 25388a3d11b9c5e627edaef1149ba053ccdbb18f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20Ve=C4=8Derek?= Date: Tue, 11 Aug 2020 11:49:14 +0200 Subject: [PATCH] Accept a path in readBundledWithFromGemfileLock --- dist/index.js | 10 +++++----- index.js | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index 52dc724..7dec8ab 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2339,9 +2339,9 @@ function setupPath(newPathEntries) { core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter)) } -function readBundledWithFromGemfileLock() { - if (fs.existsSync('Gemfile.lock')) { - const contents = fs.readFileSync('Gemfile.lock', 'utf8') +function readBundledWithFromGemfileLock(path) { + if (fs.existsSync(path)) { + const contents = fs.readFileSync(path, 'utf8') const lines = contents.split(/\r?\n/) const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim())) if (bundledWithLine !== -1) { @@ -2349,7 +2349,7 @@ function readBundledWithFromGemfileLock() { if (nextLine && /^\d+/.test(nextLine.trim())) { const bundlerVersion = nextLine.trim() const majorVersion = bundlerVersion.match(/^\d+/)[0] - console.log(`Using Bundler ${majorVersion} from Gemfile.lock BUNDLED WITH ${bundlerVersion}`) + console.log(`Using Bundler ${majorVersion} from ${path} BUNDLED WITH ${bundlerVersion}`) return majorVersion } } @@ -2361,7 +2361,7 @@ async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine, var bundlerVersion = bundlerVersionInput if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') { - bundlerVersion = readBundledWithFromGemfileLock() + bundlerVersion = readBundledWithFromGemfileLock('Gemfile.lock') if (!bundlerVersion) { bundlerVersion = 'latest' } diff --git a/index.js b/index.js index 4167487..6d9ed21 100644 --- a/index.js +++ b/index.js @@ -153,9 +153,9 @@ function setupPath(newPathEntries) { core.exportVariable('PATH', [...newPathEntries, ...cleanPath].join(path.delimiter)) } -function readBundledWithFromGemfileLock() { - if (fs.existsSync('Gemfile.lock')) { - const contents = fs.readFileSync('Gemfile.lock', 'utf8') +function readBundledWithFromGemfileLock(path) { + if (fs.existsSync(path)) { + const contents = fs.readFileSync(path, 'utf8') const lines = contents.split(/\r?\n/) const bundledWithLine = lines.findIndex(line => /^BUNDLED WITH$/.test(line.trim())) if (bundledWithLine !== -1) { @@ -163,7 +163,7 @@ function readBundledWithFromGemfileLock() { if (nextLine && /^\d+/.test(nextLine.trim())) { const bundlerVersion = nextLine.trim() const majorVersion = bundlerVersion.match(/^\d+/)[0] - console.log(`Using Bundler ${majorVersion} from Gemfile.lock BUNDLED WITH ${bundlerVersion}`) + console.log(`Using Bundler ${majorVersion} from ${path} BUNDLED WITH ${bundlerVersion}`) return majorVersion } } @@ -175,7 +175,7 @@ async function installBundler(bundlerVersionInput, platform, rubyPrefix, engine, var bundlerVersion = bundlerVersionInput if (bundlerVersion === 'default' || bundlerVersion === 'Gemfile.lock') { - bundlerVersion = readBundledWithFromGemfileLock() + bundlerVersion = readBundledWithFromGemfileLock('Gemfile.lock') if (!bundlerVersion) { bundlerVersion = 'latest' }