Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions cargo-dist/templates/installer/npm/binary-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const error = (msg) => {
};

class Package {
constructor(name, url, filename, zipExt, binaries) {
constructor(platform, name, url, filename, zipExt, binaries) {
let errors = [];
if (typeof url !== "string") {
errors.push("url must be a string");
Expand Down Expand Up @@ -47,6 +47,8 @@ class Package {
'\n\nCorrect usage: new Package("my-binary", "https://example.com/binary/download.tar.gz", {"my-binary": "my-binary"})';
error(errorMsg);
}

this.platform = platform;
this.url = url;
this.name = name;
this.filename = filename;
Expand Down Expand Up @@ -122,12 +124,30 @@ class Package {
);
}
} else if (this.zipExt == ".zip") {
const result = spawnSync("unzip", [
"-q",
tempFile,
"-d",
this.installDirectory,
]);
let result;
if (this.platform.includes("windows")) {
// Windows does not have "unzip" by default on many installations, instead
// we use Expand-Archive from powershell
result = spawnSync("powershell.exe", [
"-NoProfile",
"-NonInteractive",
"-Command",
`& {
param([string]$LiteralPath, [string]$DestinationPath)
Expand-Archive -LiteralPath $LiteralPath -DestinationPath $DestinationPath -Force
}`,
tempFile,
this.installDirectory,
]);
} else {
result = spawnSync("unzip", [
"-q",
tempFile,
"-d",
this.installDirectory,
]);
}

if (result.status == 0) {
resolve();
} else if (result.error) {
Expand Down
2 changes: 1 addition & 1 deletion cargo-dist/templates/installer/npm/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const getPackage = () => {
const url = `${artifactDownloadUrl}/${platform.artifactName}`;
let filename = platform.artifactName;
let ext = platform.zipExt;
let binary = new Package(name, url, filename, ext, platform.bins);
let binary = new Package(platform, name, url, filename, ext, platform.bins);

return binary;
};
Expand Down
36 changes: 28 additions & 8 deletions cargo-dist/tests/snapshots/axolotlsay_action_commit.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions cargo-dist/tests/snapshots/axolotlsay_alias.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions cargo-dist/tests/snapshots/axolotlsay_attestations_filters.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 28 additions & 8 deletions cargo-dist/tests/snapshots/axolotlsay_attestations_host.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading