Skip to content

Commit

Permalink
Changed 7z compression options to be YAML-friendly string values. Add…
Browse files Browse the repository at this point in the history
…ressed other feedback.
  • Loading branch information
alexwiese committed Apr 30, 2018
1 parent 716011f commit b259644
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
26 changes: 23 additions & 3 deletions Tasks/ArchiveFiles/archivefiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ function sevenZipArchive(archive: string, compression: string, files: string[])
sevenZip.arg('a');
sevenZip.arg('-t' + compression);

const sevenZipCompression = tl.getInput('sevenZipCompression', false);
if(sevenZipCompression) {
sevenZip.arg('-mx=' + sevenZipCompression);
const sevenZipCompression = tl.getInput('sevenZipCompression', false);
if (sevenZipCompression) {
sevenZip.arg('-mx=' + mapSevenZipCompressionLevel(sevenZipCompression));
}

sevenZip.arg(archive);
Expand All @@ -92,6 +92,26 @@ function sevenZipArchive(archive: string, compression: string, files: string[])
return handleExecResult(sevenZip.execSync(getOptions()), archive);
}

// map from YAML-friendly value to 7-Zip numeric value
function mapSevenZipCompressionLevel(sevenZipCompression: string) {
switch (sevenZipCompression) {
case "ultra":
return "9";
case "maximum":
return "7";
case "normal":
return "5";
case "fast":
return "3";
case "fastest":
return "1";
case "none":
return "0";
default:
return "5";
}
}

// linux & mac only
function zipArchive(archive: string, files: string[]) {
tl.debug('Creating archive with zip: ' + archive);
Expand Down
14 changes: 7 additions & 7 deletions Tasks/ArchiveFiles/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 128,
"Minor": 135,
"Patch": 0
},
"groups": [
Expand Down Expand Up @@ -70,12 +70,12 @@
"groupName": "archive",
"visibleRule": "archiveType = 7z",
"options": {
"9": "Ultra",
"7": "Maximum",
"5": "Normal",
"3": "Fast",
"1": "Fastest",
"0": "None"
"ultra": "Ultra",
"maximum": "Maximum",
"normal": "Normal",
"fast": "Fast",
"fastest": "Fastest",
"none": "None"
}
},
{
Expand Down
14 changes: 7 additions & 7 deletions Tasks/ArchiveFiles/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 128,
"Minor": 135,
"Patch": 0
},
"groups": [
Expand Down Expand Up @@ -70,12 +70,12 @@
"groupName": "archive",
"visibleRule": "archiveType = 7z",
"options": {
"0": "None",
"1": "Fastest",
"3": "Fast",
"5": "Normal",
"7": "Maximum",
"9": "Ultra"
"ultra": "Ultra",
"maximum": "Maximum",
"normal": "Normal",
"fast": "Fast",
"fastest": "Fastest",
"none": "None"
}
},
{
Expand Down

0 comments on commit b259644

Please sign in to comment.