@@ -6,6 +6,7 @@ const cache = require('@actions/cache')
66const common = require ( './common' )
77
88export const DEFAULT_CACHE_VERSION = '0'
9+ export const BUNDLER_VERSION_REGEXP = / ^ \d + (?: \. \d + ) { 0 , 2 } $ /
910
1011// The returned gemfile is guaranteed to exist, the lockfile might not exist
1112export function detectGemfiles ( ) {
@@ -30,10 +31,14 @@ function readBundledWithFromGemfileLock(lockFile) {
3031 const bundledWithLine = lines . findIndex ( line => / ^ B U N D L E D W I T H $ / . test ( line . trim ( ) ) )
3132 if ( bundledWithLine !== - 1 ) {
3233 const nextLine = lines [ bundledWithLine + 1 ]
33- if ( nextLine && / ^ \d + / . test ( nextLine . trim ( ) ) ) {
34+ if ( nextLine ) {
3435 const bundlerVersion = nextLine . trim ( )
35- console . log ( `Using Bundler ${ bundlerVersion } from ${ lockFile } BUNDLED WITH ${ bundlerVersion } ` )
36- return bundlerVersion
36+ if ( BUNDLER_VERSION_REGEXP . test ( bundlerVersion ) ) {
37+ console . log ( `Using Bundler ${ bundlerVersion } from ${ lockFile } BUNDLED WITH ${ bundlerVersion } ` )
38+ return bundlerVersion
39+ } else {
40+ console . log ( `Could not parse BUNDLED WITH version as a valid Bundler release, ignoring it: ${ bundlerVersion } ` )
41+ }
3742 }
3843 }
3944 }
@@ -95,7 +100,7 @@ export async function installBundler(bundlerVersionInput, rubygemsInputSet, lock
95100 bundlerVersion = '2'
96101 }
97102
98- if ( / ^ \d + (?: \. \d + ) { 0 , 2 } $ / . test ( bundlerVersion ) ) {
103+ if ( BUNDLER_VERSION_REGEXP . test ( bundlerVersion ) ) {
99104 // OK - input is a 1, 2, or 3 part version number
100105 } else {
101106 throw new Error ( `Cannot parse bundler input: ${ bundlerVersion } ` )
0 commit comments