Skip to content

Commit

Permalink
fix: Switch to use a regex to filter out results instead of length (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryantbiggs authored Nov 13, 2022
1 parent 3c5b175 commit 6a81ce9
Show file tree
Hide file tree
Showing 5 changed files with 550 additions and 502 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,22 @@
"@actions/core": "^1.10.0",
"@actions/io": "^1.1.2",
"find-in-files": "^0.5.0",
"node-fetch": "^3.2.10",
"node-fetch": "^3.3.0",
"semver": "^7.3.8"
},
"devDependencies": {
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"@types/find-in-files": "^0.5.1",
"@types/node": "^18.11.7",
"@types/node": "^18.11.9",
"@types/node-fetch": "^2.6.2",
"@types/semver": "^7.3.13",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"@vercel/ncc": "^0.34.0",
"commitizen": "^4.2.5",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.26.0",
"eslint": "^8.27.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.2.1",
Expand Down
3 changes: 2 additions & 1 deletion src/search.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import * as findInFiles from 'find-in-files';

const regExprRequiredVersion = /(?<=(required_version.=.)).*/;
const regExprFilename = /^(versions|providers).tf$/;

export async function versionConstraintSearch(dir: string): Promise<string> {
const files = await findInFiles.find('required_versions*s*', dir, '.tf$');
const key = Object.keys(files).sort((a, b) => a.length - b.length)[0];
const key = Object.keys(files).filter(word => !regExprFilename.test(word))[0];
const line = files[key].line;

if (line) {
Expand Down
10 changes: 10 additions & 0 deletions tests/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
terraform {
required_version = ">= 1.0.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.27"
}
}
}
Loading

0 comments on commit 6a81ce9

Please sign in to comment.