From 8f0e8b0890952ad94f9d4f1a44170b0f27723054 Mon Sep 17 00:00:00 2001 From: Henry Mercer Date: Thu, 5 Oct 2023 16:26:47 +0100 Subject: [PATCH] Tweak language parsing to improve clarity --- lib/resolve-environment.js | 8 +++----- lib/resolve-environment.js.map | 2 +- src/resolve-environment.ts | 9 +++++---- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/resolve-environment.js b/lib/resolve-environment.js index f779e38f16..60913729fa 100644 --- a/lib/resolve-environment.js +++ b/lib/resolve-environment.js @@ -31,11 +31,9 @@ async function runResolveBuildEnvironment(cmd, logger, workingDir, languageInput logger.startGroup(`Attempting to resolve build environment for ${languageInput}`); const codeql = await (0, codeql_1.getCodeQL)(cmd); let language = languageInput; - if (await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_LANGUAGE_ALIASING)) { - // Delegate to the CodeQL CLI to handle aliasing. - } - else { - // Handle aliasing in the Action using `parseLanguage`. + // If the CodeQL CLI version in use supports language aliasing, give the CLI the raw language + // input. Otherwise, parse the language input and give the CLI the parsed language. + if (!(await util.codeQlVersionAbove(codeql, codeql_1.CODEQL_VERSION_LANGUAGE_ALIASING))) { const parsedLanguage = (0, languages_1.parseLanguage)(languageInput)?.toString(); if (parsedLanguage === undefined) { throw new Error(`Did not recognize the language '${languageInput}'.`); diff --git a/lib/resolve-environment.js.map b/lib/resolve-environment.js.map index 1ee04cebe7..68d875326a 100644 --- a/lib/resolve-environment.js.map +++ b/lib/resolve-environment.js.map @@ -1 +1 @@ -{"version":3,"file":"resolve-environment.js","sourceRoot":"","sources":["../src/resolve-environment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAIkB;AAClB,2CAA4C;AAE5C,6CAA+B;AAExB,KAAK,UAAU,0BAA0B,CAC9C,GAAW,EACX,MAAc,EACd,UAA8B,EAC9B,aAAqB;IAErB,MAAM,CAAC,UAAU,CACf,+CAA+C,aAAa,EAAE,CAC/D,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC;IAEpC,IAAI,QAAQ,GAAG,aAAa,CAAC;IAC7B,IAAI,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,yCAAgC,CAAC,EAAE;QAC3E,iDAAiD;KAClD;SAAM;QACL,uDAAuD;QACvD,MAAM,cAAc,GAAG,IAAA,yBAAa,EAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;QAChE,IAAI,cAAc,KAAK,SAAS,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,mCAAmC,aAAa,IAAI,CAAC,CAAC;SACvE;QACD,QAAQ,GAAG,cAAc,CAAC;KAC3B;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,gFAAgF;IAChF,yEAAyE;IACzE,IACE,CAAC,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,2CAAkC,CAAC,CAAC,EAC5E;QACA,MAAM,CAAC,OAAO,CACZ,0EAA0E;YACxE,mCAAmC,CACtC,CAAC;KACH;SAAM;QACL,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,SAAS,UAAU,4BAA4B,CAAC,CAAC;SAC9D;QAED,MAAM,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;KACrE;IAED,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,MAAM,CAAC;AAChB,CAAC;AA7CD,gEA6CC"} \ No newline at end of file +{"version":3,"file":"resolve-environment.js","sourceRoot":"","sources":["../src/resolve-environment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAIkB;AAClB,2CAA4C;AAE5C,6CAA+B;AAExB,KAAK,UAAU,0BAA0B,CAC9C,GAAW,EACX,MAAc,EACd,UAA8B,EAC9B,aAAqB;IAErB,MAAM,CAAC,UAAU,CACf,+CAA+C,aAAa,EAAE,CAC/D,CAAC;IAEF,MAAM,MAAM,GAAG,MAAM,IAAA,kBAAS,EAAC,GAAG,CAAC,CAAC;IAEpC,IAAI,QAAQ,GAAG,aAAa,CAAC;IAC7B,6FAA6F;IAC7F,mFAAmF;IACnF,IACE,CAAC,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,yCAAgC,CAAC,CAAC,EAC1E;QACA,MAAM,cAAc,GAAG,IAAA,yBAAa,EAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;QAChE,IAAI,cAAc,KAAK,SAAS,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,mCAAmC,aAAa,IAAI,CAAC,CAAC;SACvE;QACD,QAAQ,GAAG,cAAc,CAAC;KAC3B;IAED,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,gFAAgF;IAChF,yEAAyE;IACzE,IACE,CAAC,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,2CAAkC,CAAC,CAAC,EAC5E;QACA,MAAM,CAAC,OAAO,CACZ,0EAA0E;YACxE,mCAAmC,CACtC,CAAC;KACH;SAAM;QACL,IAAI,UAAU,KAAK,SAAS,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,SAAS,UAAU,4BAA4B,CAAC,CAAC;SAC9D;QAED,MAAM,GAAG,MAAM,MAAM,CAAC,uBAAuB,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;KACrE;IAED,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,MAAM,CAAC;AAChB,CAAC;AA9CD,gEA8CC"} \ No newline at end of file diff --git a/src/resolve-environment.ts b/src/resolve-environment.ts index 826bee3237..43d0f48e0d 100644 --- a/src/resolve-environment.ts +++ b/src/resolve-environment.ts @@ -20,10 +20,11 @@ export async function runResolveBuildEnvironment( const codeql = await getCodeQL(cmd); let language = languageInput; - if (await util.codeQlVersionAbove(codeql, CODEQL_VERSION_LANGUAGE_ALIASING)) { - // Delegate to the CodeQL CLI to handle aliasing. - } else { - // Handle aliasing in the Action using `parseLanguage`. + // If the CodeQL CLI version in use supports language aliasing, give the CLI the raw language + // input. Otherwise, parse the language input and give the CLI the parsed language. + if ( + !(await util.codeQlVersionAbove(codeql, CODEQL_VERSION_LANGUAGE_ALIASING)) + ) { const parsedLanguage = parseLanguage(languageInput)?.toString(); if (parsedLanguage === undefined) { throw new Error(`Did not recognize the language '${languageInput}'.`);