Skip to content

Commit 42380be

Browse files
tehraninasabwebwarrior-ws
authored andcommitted
FileConventions: fix the function
Fix DetectUnpinnedNpmPackageInstallVersions function.
1 parent 6e03e11 commit 42380be

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/FileConventions/Library.fs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,15 @@ let DetectUnpinnedNpmPackageInstallVersions(fileInfo: FileInfo) =
9898
let npmPackageInstallRegex =
9999
Regex("npm\\s+install\\s+", RegexOptions.Compiled)
100100

101+
let npmPackageVersionRegex =
102+
Regex("@((\\d+\\.\\d+\\.\\d+)|(\\$[A-Z_]+))", RegexOptions.Compiled)
103+
101104
let unpinnedNpmPackageInstallVersions =
102105
fileLines
103-
|> Seq.filter(fun line -> npmPackageInstallRegex.IsMatch line)
104-
|> Seq.filter(fun line -> not(line.Contains "@"))
106+
|> Seq.filter(fun line ->
107+
npmPackageInstallRegex.IsMatch line
108+
&& npmPackageVersionRegex.IsMatch line |> not
109+
)
105110
|> (fun unpinnedVersions -> Seq.length unpinnedVersions > 0)
106111

107112
unpinnedNpmPackageInstallVersions

0 commit comments

Comments
 (0)