Skip to content

Commit

Permalink
fix(cake): quoted references (#9692)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
nils-a and viceice committed Apr 23, 2021
1 parent 9e2d276 commit 37a8e28
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/manager/cake/__fixtures__/build.cake
@@ -1,5 +1,6 @@
foo
#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
#module nuget:file:///tmp/?package=Baz.Baz&version=3.3.3
// #module nuget:?package=Qux.Qux&version=4.4.4
Expand Down
5 changes: 5 additions & 0 deletions lib/manager/cake/__snapshots__/index.spec.ts.snap
Expand Up @@ -8,6 +8,11 @@ Object {
"datasource": "nuget",
"depName": "Foo.Foo",
},
Object {
"currentValue": "6.6.6",
"datasource": "nuget",
"depName": "Bim.Bim",
},
Object {
"currentValue": "2.2.2",
"datasource": "nuget",
Expand Down
7 changes: 6 additions & 1 deletion lib/manager/cake/index.ts
Expand Up @@ -17,6 +17,10 @@ const lexerStates = {
dependency: {
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 },
},
};
Expand All @@ -26,6 +30,7 @@ function parseDependencyLine(line: string): PackageDependency | null {
let url = line.replace(/^[^:]*:/, '');
const isEmptyHost = url.startsWith('?');
url = isEmptyHost ? `http://localhost/${url}` : url;

const { origin: registryUrl, protocol, searchParams } = new URL(url);

const depName = searchParams.get('package');
Expand Down Expand Up @@ -54,7 +59,7 @@ export function extractPackageFile(content: string): PackageFile {
let token = lexer.next();
while (token) {
const { type, value } = token;
if (type === 'dependency') {
if (type === 'dependency' || type === 'dependencyQuoted') {
const dep = parseDependencyLine(value);
if (dep) {
deps.push(dep);
Expand Down

0 comments on commit 37a8e28

Please sign in to comment.