Skip to content

Commit

Permalink
feat: allow to skip download with BINDL_SKIP
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Dec 5, 2022
1 parent e75435d commit bc69ed8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Download and extract binaries from compressed packages.
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

<!-- toc -->
* [bindl](#bindl)
* [Usage](#usage)
- [bindl](#bindl)
- [Usage](#usage)
<!-- tocstop -->

# Usage
Expand Down Expand Up @@ -50,6 +50,8 @@ DESCRIPTION

You can find an example of config file [here](./test/res/bindl.config.js).

You can also skip the downloads by setting the `BINDL_SKIP` environment variable to a truthy value.

<!-- commands -->

<!-- commandsstop -->
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class Bindl extends Command {
async run(): Promise<void> {
const { flags } = this.parse(Bindl);

// Return early if BINDL_SKIP is set
if (process.env.BINDL_SKIP) {
this.log("Skipping download due to the BINDL_SKIP env var being set");
return;
}

const explorer = cosmiconfig(this.config.name);

const result = flags.config
Expand Down
28 changes: 13 additions & 15 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,8 @@ describe("bindl", () => {
expect(
shell.test("-f", "./binaries/win32/ia32/shellcheck.exe")
).toBeTruthy();
expect(
shell.test("-f", "./binaries/win32/ia32/LICENSE.txt")
).toBeTruthy();
expect(
shell.test("-f", "./binaries/win32/ia32/README.txt")
).toBeTruthy();
expect(shell.test("-f", "./binaries/win32/ia32/LICENSE.txt")).toBeTruthy();
expect(shell.test("-f", "./binaries/win32/ia32/README.txt")).toBeTruthy();
});

it("downloads only linux-arm64 binary when npm_config_arch is set", async () => {
Expand All @@ -67,17 +63,19 @@ 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/win32/x64/shellcheck.exe")
).toBeFalsy();
expect(shell.test("-f", "./binaries/win32/x64/shellcheck.exe")).toBeFalsy();
expect(
shell.test("-f", "./binaries/win32/ia32/shellcheck.exe")
).toBeFalsy();
expect(
shell.test("-f", "./binaries/win32/ia32/LICENSE.txt")
).toBeFalsy();
expect(
shell.test("-f", "./binaries/win32/ia32/README.txt")
).toBeFalsy();
expect(shell.test("-f", "./binaries/win32/ia32/LICENSE.txt")).toBeFalsy();
expect(shell.test("-f", "./binaries/win32/ia32/README.txt")).toBeFalsy();
});

it("downloads nothing when BINDL_SKIP is set", async () => {
const result = await execa.command(`${bin} --config ${configPath}`, {
env: { BINDL_SKIP: "true" },
});
expect(result.stdout).toContain(`Skipping`);
expect(result.exitCode).toBe(0);
});
});

0 comments on commit bc69ed8

Please sign in to comment.