Skip to content

Commit

Permalink
FileConventions: implement the function
Browse files Browse the repository at this point in the history
Implement DetectUnpinnedNpmPackageInstallVersions function.
  • Loading branch information
tehraninasab committed Jul 6, 2023
1 parent f139e8b commit 222cd21
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/FileConventions/Library.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,20 @@ let DetectUnpinnedDotnetToolInstallVersions(fileInfo: FileInfo) =
unpinnedDotnetToolInstallVersions

let DetectUnpinnedNpmPackageInstallVersions(fileInfo: FileInfo) =
printfn "File Path: %s" fileInfo.FullName
false
assert fileInfo.FullName.EndsWith ".yml"

let fileLines = File.ReadLines fileInfo.FullName

let npmPackageInstallRegex =
Regex("npm\\s+install\\s+", RegexOptions.Compiled)

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

unpinnedNpmPackageInstallVersions

let DetectAsteriskInPackageReferenceItems(fileInfo: FileInfo) =
assert (fileInfo.FullName.EndsWith "proj")
Expand Down

0 comments on commit 222cd21

Please sign in to comment.