From 8250970624bba09f5d3e3b396c9cd0f521b8220b Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Sat, 12 Nov 2022 08:16:26 -0500 Subject: [PATCH] fix: Add sort ascending by string length in versions.tf files keys array (#15) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Juan Ramón Sixto Anello <5945892+jotasixto@users.noreply.github.com> --- src/search.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/search.ts b/src/search.ts index af5945a..8c07943 100644 --- a/src/search.ts +++ b/src/search.ts @@ -4,7 +4,7 @@ const regExprRequiredVersion = /(?<=(required_version.=.)).*/; export async function versionConstraintSearch(dir: string): Promise { const files = await findInFiles.find('required_versions*s*', dir, '.tf$'); - const key = Object.keys(files)[0]; + const key = Object.keys(files).sort((a, b) => a.length - b.length)[0]; const line = files[key].line; if (line) {