Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cake): quoted references #9692

Merged
merged 3 commits into from Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
nils-a marked this conversation as resolved.
Show resolved Hide resolved
#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*$/,
nils-a marked this conversation as resolved.
Show resolved Hide resolved
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