Skip to content

Commit

Permalink
feat!: support custom decompress plugins, drop support for xz by default
Browse files Browse the repository at this point in the history
Through a `decompressPlugins` array in the config file, users can
specify custom decompress plugins.

You can restore the previous support for xz files by adding the
following to your config file:

```js
// bindl.config.js

module.exports = {
  decompressPlugins: [
    "@felipecrs/decompress-tarxz"
  ],
  binaries: [
    // ...
  ]
}
```
  • Loading branch information
felipecrs committed Nov 17, 2022
1 parent f57ae07 commit 492b1ca
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
19 changes: 16 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
},
"bugs": "https://github.com/felipecrs/bindl/issues",
"dependencies": {
"@felipecrs/decompress-tarxz": "^4.0.0",
"@oclif/command": "^1.8.0",
"@oclif/config": "^1.17.0",
"@oclif/plugin-help": "^3.2.0",
Expand All @@ -26,6 +25,7 @@
"devDependencies": {
"@commitlint/cli": "^12.0.0",
"@commitlint/config-conventional": "^12.0.0",
"@felipecrs/decompress-tarxz": "^4.0.0",
"@oclif/dev-cli": "^1.22.2",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
Expand Down
8 changes: 7 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@ class Bindl extends Command {
require("decompress-tarbz2")(),
require("decompress-targz")(),
require("decompress-unzip")(),
require("@felipecrs/decompress-tarxz")(),
];

// Load the custom decompressPlugins
if (result.config.decompressPlugins && result.config.decompressPlugins.length > 0) {
for (const plugin of result.config.decompressPlugins) {
plugins.push(require(plugin)());
}
}

result.config.binaries.forEach(
async (binary: {
platform: "linux" | "darwin" | "win32";
Expand Down
2 changes: 0 additions & 2 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe("bindl", () => {
expect(shell.test("-f", "./binaries/linux/arm/shellcheck")).toBeTruthy();
expect(shell.test("-f", "./binaries/linux/arm64/shellcheck")).toBeTruthy();
expect(shell.test("-f", "./binaries/darwin/x64/shellcheck")).toBeTruthy();
expect(shell.test("-f", "./binaries/darwin/arm64/shellcheck")).toBeTruthy();
expect(
shell.test("-f", "./binaries/win32/x32/shellcheck.exe")
).toBeTruthy();
Expand Down Expand Up @@ -62,7 +61,6 @@ describe("bindl", () => {
}
expect(shell.test("-f", "./binaries/linux/arm/shellcheck")).toBeFalsy();
expect(shell.test("-f", "./binaries/linux/arm64/shellcheck")).toBeFalsy();
expect(shell.test("-f", "./binaries/darwin/arm64/shellcheck")).toBeFalsy();
expect(shell.test("-f", "./binaries/win32/x32/shellcheck.exe")).toBeFalsy();
});
});
17 changes: 3 additions & 14 deletions test/res/bindl.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const version = "v0.8.0";
const shortVersion = version.substring(1);
const shellcheckReleaseUrl = `https://github.com/koalaman/shellcheck/releases/download/${version}/shellcheck-${version}`;
const shellcheckM1DownloadBaseUrl = `https://github.com/vscode-shellcheck/shellcheck-m1/releases/download/${version}/`;

module.exports = {
decompressPlugins: [
"@felipecrs/decompress-tarxz"
],
binaries: [
{
platform: "linux",
Expand Down Expand Up @@ -49,18 +50,6 @@ module.exports = {
},
],
},
{
platform: "darwin",
arch: "arm64",
// Sync from homebrew
url: `${shellcheckM1DownloadBaseUrl}shellcheck-${shortVersion}.tar.gz`,
files: [
{
source: `shellcheck/${shortVersion}/bin/shellcheck`,
target: "shellcheck",
},
],
},
{
platform: "win32",
arch: "x32",
Expand Down

0 comments on commit 492b1ca

Please sign in to comment.