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 1 commit
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
12 changes: 10 additions & 2 deletions lib/manager/cake/index.ts
Expand Up @@ -17,15 +17,23 @@ 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
},
unknown: { match: /[^]/, lineBreaks: true },
},
};

function parseDependencyLine(line: string): PackageDependency | null {
try {
let url = line.replace(/^[^:]*:/, '');
let url = line.replace(/^[^:]*:/, '').trimEnd();
nils-a marked this conversation as resolved.
Show resolved Hide resolved
const isEmptyHost = url.startsWith('?');
url = isEmptyHost ? `http://localhost/${url}` : url;

if (url.endsWith('"')) {
url = url.slice(0, -1);
}

nils-a marked this conversation as resolved.
Show resolved Hide resolved
const { origin: registryUrl, protocol, searchParams } = new URL(url);

const depName = searchParams.get('package');
Expand Down Expand Up @@ -54,7 +62,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