Skip to content
Snippets Groups Projects
Unverified Commit f4f89e12 authored by RahulGautamSingh's avatar RahulGautamSingh Committed by GitHub
Browse files

fix(manager/mix): ignore comments when extracting deps (#18479)

parent 58c9b151
No related branches found
No related tags found
No related merge requests found
......@@ -16,14 +16,18 @@ defmodule MyProject.MixProject do
defp deps() do
[
{:postgrex, "~> 0.8.1"},
#{:broadway_dashboard, "~> 0.2.2"},
#{:broadway_dashboard, "~> 0.2.2"},
# {:broadway_dashboard, "~> 0.2.2"},
# {:broadway_dashboard, "~> 0.2.2"},
{:postgrex, "~> 0.8.1"}, # {:broadway_dashboard, "~> 0.2.2"},
{:ecto, ">2.1.0 or <=3.0.0"},
{:cowboy, github: "ninenines/cowboy"},
{:secret, "~> 1.0", organization: "acme"},
{:ex_doc, ">2.1.0 and <=3.0.0"},
{:jason, ">= 1.0.0"},
{:jason, "~> 1.0",
{:jason, "~> 1.0",
optional: true},
]
end
end
\ No newline at end of file
end
......@@ -8,6 +8,7 @@ const depSectionRegExp = regEx(/defp\s+deps.*do/g);
const depMatchRegExp = regEx(
/{:(?<depName>\w+),\s*(?<datasource>[^:"]+)?:?\s*"(?<currentValue>[^"]+)",?\s*(?:organization: "(?<organization>.*)")?.*}/gm
);
const commentMatchRegExp = regEx(/^\s*#/);
export async function extractPackageFile(
content: string,
......@@ -15,8 +16,9 @@ export async function extractPackageFile(
): Promise<PackageFile | null> {
logger.trace('mix.extractPackageFile()');
const deps: PackageDependency[] = [];
const contentArr = content.split(newlineRegex);
const contentArr = content
.split(newlineRegex)
.filter((line) => !commentMatchRegExp.test(line));
for (let lineNumber = 0; lineNumber < contentArr.length; lineNumber += 1) {
if (contentArr[lineNumber].match(depSectionRegExp)) {
logger.trace(`Matched dep section on line ${lineNumber}`);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment