Skip to content
Snippets Groups Projects
Unverified Commit 37a8e282 authored by Nils Andresen's avatar Nils Andresen Committed by GitHub
Browse files

fix(cake): quoted references (#9692)

parent 9e2d2763
No related branches found
No related tags found
No related merge requests found
foo foo
#addin nuget:?package=Foo.Foo&version=1.1.1 #addin nuget:?package=Foo.Foo&version=1.1.1
#addin "nuget:?package=Bim.Bim&version=6.6.6"
#tool nuget:https://example.com?package=Bar.Bar&version=2.2.2 #tool nuget:https://example.com?package=Bar.Bar&version=2.2.2
#module nuget:file:///tmp/?package=Baz.Baz&version=3.3.3 #module nuget:file:///tmp/?package=Baz.Baz&version=3.3.3
// #module nuget:?package=Qux.Qux&version=4.4.4 // #module nuget:?package=Qux.Qux&version=4.4.4
......
...@@ -8,6 +8,11 @@ Object { ...@@ -8,6 +8,11 @@ Object {
"datasource": "nuget", "datasource": "nuget",
"depName": "Foo.Foo", "depName": "Foo.Foo",
}, },
Object {
"currentValue": "6.6.6",
"datasource": "nuget",
"depName": "Bim.Bim",
},
Object { Object {
"currentValue": "2.2.2", "currentValue": "2.2.2",
"datasource": "nuget", "datasource": "nuget",
......
...@@ -17,6 +17,10 @@ const lexerStates = { ...@@ -17,6 +17,10 @@ const lexerStates = {
dependency: { dependency: {
match: /^#(?:addin|tool|module)\s+(?:nuget|dotnet):.*$/, match: /^#(?:addin|tool|module)\s+(?:nuget|dotnet):.*$/,
}, },
dependencyQuoted: {
match: /^#(?:addin|tool|module)\s+"(?:nuget|dotnet):[^"]+"\s*$/,
value: (s: string) => s.trim().slice(1, -1),
},
unknown: { match: /[^]/, lineBreaks: true }, unknown: { match: /[^]/, lineBreaks: true },
}, },
}; };
...@@ -26,6 +30,7 @@ function parseDependencyLine(line: string): PackageDependency | null { ...@@ -26,6 +30,7 @@ function parseDependencyLine(line: string): PackageDependency | null {
let url = line.replace(/^[^:]*:/, ''); let url = line.replace(/^[^:]*:/, '');
const isEmptyHost = url.startsWith('?'); const isEmptyHost = url.startsWith('?');
url = isEmptyHost ? `http://localhost/${url}` : url; url = isEmptyHost ? `http://localhost/${url}` : url;
const { origin: registryUrl, protocol, searchParams } = new URL(url); const { origin: registryUrl, protocol, searchParams } = new URL(url);
const depName = searchParams.get('package'); const depName = searchParams.get('package');
...@@ -54,7 +59,7 @@ export function extractPackageFile(content: string): PackageFile { ...@@ -54,7 +59,7 @@ export function extractPackageFile(content: string): PackageFile {
let token = lexer.next(); let token = lexer.next();
while (token) { while (token) {
const { type, value } = token; const { type, value } = token;
if (type === 'dependency') { if (type === 'dependency' || type === 'dependencyQuoted') {
const dep = parseDependencyLine(value); const dep = parseDependencyLine(value);
if (dep) { if (dep) {
deps.push(dep); deps.push(dep);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment