Skip to content

Commit

Permalink
FileConventions: fix the function
Browse files Browse the repository at this point in the history
Fix DetectUnpinnedNpmPackageInstallVersions function.
  • Loading branch information
tehraninasab committed Jul 13, 2023
1 parent 08e1045 commit 61ed51e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/FileConventions/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,15 @@ let DetectUnpinnedNpmPackageInstallVersions(fileInfo: FileInfo) =
let npmPackageInstallRegex =
Regex("npm\\s+install\\s+", RegexOptions.Compiled)

let npmPackageVersionRegex =
Regex("@\\d+\\.\\d+\\.\\d+", RegexOptions.Compiled)

let unpinnedNpmPackageInstallVersions =
fileLines
|> Seq.filter(fun line -> npmPackageInstallRegex.IsMatch line)
|> Seq.filter(fun line -> not(line.Contains "@"))
|> Seq.filter(fun line ->
npmPackageInstallRegex.IsMatch line
&& npmPackageVersionRegex.IsMatch line |> not
)
|> (fun unpinnedVersions -> Seq.length unpinnedVersions > 0)

unpinnedNpmPackageInstallVersions
Expand Down

0 comments on commit 61ed51e

Please sign in to comment.