Address code review feedback

This commit is contained in:
Andreas Braun
2021-01-25 13:39:13 +01:00
committed by Shivam Mathur
parent f42065d568
commit 26791e8412
5 changed files with 89 additions and 81 deletions

View File

@ -17,21 +17,7 @@ export async function addExtensionDarwin(
const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name);
// Install extensions from a GitHub tarball. This needs to be checked first
// as the version may also match the semver check below.
const urlMatches = extension.match(/.*-(.*)\/(.*)@(.*)/);
if (urlMatches != null) {
add_script += await utils.joins(
'\nadd_extension_from_github',
ext_name,
urlMatches[1],
urlMatches[2],
urlMatches[3],
ext_prefix
);
return;
}
let matches: RegExpExecArray;
switch (true) {
// match :extension
@ -69,6 +55,28 @@ export async function addExtensionDarwin(
ext_prefix
);
return;
// match extensions from GitHub. Do this before checking for semver as
// the version may match that as well
case /.*-(.*)\/(.*)@(.*)/.test(extension):
matches = /.*-(.*)\/(.*)@(.*)/.exec(extension) as RegExpExecArray;
if (matches == null) {
// Shouldn't happen
add_script += await utils.getUnsupportedLog(
extension,
version,
'darwin'
);
return;
}
add_script += await utils.joins(
'\nadd_extension_from_github',
ext_name,
matches[1],
matches[2],
matches[3],
ext_prefix
);
return;
// match semver
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
add_script += await utils.joins(
@ -239,21 +247,7 @@ export async function addExtensionLinux(
const version_extension: string = version + extension;
const [ext_name, ext_version]: string[] = extension.split('-');
const ext_prefix = await utils.getExtensionPrefix(ext_name);
// Install extensions from a GitHub tarball. This needs to be checked first
// as the version may also match the semver check below.
const urlMatches = extension.match(/.*-(.*)\/(.*)@(.*)/);
if (urlMatches != null) {
add_script += await utils.joins(
'\nadd_extension_from_github',
ext_name,
urlMatches[1],
urlMatches[2],
urlMatches[3],
ext_prefix
);
return;
}
let matches: RegExpExecArray;
switch (true) {
// Match :extension
@ -296,6 +290,28 @@ export async function addExtensionLinux(
ext_prefix
);
return;
// match extensions from GitHub. Do this before checking for semver as
// the version may match that as well
case /.*-(.*)\/(.*)@(.*)/.test(extension):
matches = /.*-(.*)\/(.*)@(.*)/.exec(extension) as RegExpExecArray;
if (matches == null) {
// Shouldn't happen
add_script += await utils.getUnsupportedLog(
extension,
version,
'linux'
);
return;
}
add_script += await utils.joins(
'\nadd_extension_from_github',
ext_name,
matches[1],
matches[2],
matches[3],
ext_prefix
);
return;
// match semver versions
case /.*-\d+\.\d+\.\d+.*/.test(version_extension):
add_script += await utils.joins(