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 e382c3d commit 1433c8e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/FileConventions/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,22 @@ let DetectUnpinnedNpmPackageInstallVersions(fileInfo: FileInfo) =

let unpinnedNpmPackageInstallVersions =
fileLines
|> Seq.filter(fun line -> npmPackageInstallRegex.IsMatch line)
|> Seq.filter(fun line ->
npmPackageInstallRegex.IsMatch line
&& npmPackageVersionRegex.IsMatch line |> not
let npmPackagesRegex =
Regex("(?<=npm install ).*$", RegexOptions.Compiled)

let npmInstallPackages = npmPackagesRegex.Match line

let numNpmInstallPackages =
npmInstallPackages.Value.Split(" ")
|> Seq.filter(fun word -> word.Trim().StartsWith("-") |> not)
|> Seq.length

let numNpmInstallVersions =
npmPackageVersionRegex.Matches line |> Seq.length

numNpmInstallPackages = numNpmInstallVersions |> not
)
|> (fun unpinnedVersions -> Seq.length unpinnedVersions > 0)

Expand Down

0 comments on commit 1433c8e

Please sign in to comment.