Skip to content

Commit

Permalink
Add no-cache option (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
maschwenk authored Feb 23, 2024
1 parent 0f37bd8 commit d360327
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ In most cases, you shouldn't need to use the [setup-node](https://github.com/act
| `bun-version` | The version of Bun to download and install. | `latest` | `canary`, `1.0.0`, `1.0.x` |
| `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` |
| `scope` | Scope for private packages. | `undefined` | `"@foo"`, `"@orgname"` |
| `no-cache` | Disable caching of the downloaded executable. | `false` | `true`, `false` |

## Outputs

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ inputs:
scope:
required: false
description: "The scope for authenticating with the package registry."
no-cache:
required: false
type: boolean
default: false
description: "Disable caching of bun executable."
outputs:
bun-version:
description: The version of Bun that was installed.
Expand Down
38 changes: 19 additions & 19 deletions dist/setup/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 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
@@ -1,7 +1,7 @@
{
"private": true,
"name": "setup-bun",
"version": "1.1.1",
"version": "1.2.0",
"description": "Setup Bun on GitHub Actions.",
"keywords": [
"bun",
Expand Down
6 changes: 5 additions & 1 deletion src/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type Input = {
profile?: boolean;
scope?: string;
registryUrl?: string;
noCache?: boolean;
};

export type Output = {
Expand Down Expand Up @@ -123,7 +124,10 @@ export default async (options: Input): Promise<Output> => {
};

function isCacheEnabled(options: Input): boolean {
const { customUrl, version } = options;
const { customUrl, version, noCache } = options;
if (noCache) {
return false;
}
if (customUrl) {
return false;
}
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { tmpdir } from "node:os";
import { join } from "node:path";
import { existsSync, readFileSync } from "node:fs";
import { getInput, setOutput, setFailed, warning } from "@actions/core";
import {
getInput,
setOutput,
setFailed,
warning,
getBooleanInput,
} from "@actions/core";
import runAction from "./action.js";

if (!process.env.RUNNER_TEMP) {
Expand Down Expand Up @@ -35,6 +41,7 @@ runAction({
customUrl: getInput("bun-download-url") || undefined,
registryUrl: getInput("registry-url") || undefined,
scope: getInput("scope") || undefined,
noCache: getBooleanInput("no-cache") || false,
})
.then(({ version, revision, cacheHit }) => {
setOutput("bun-version", version);
Expand Down

0 comments on commit d360327

Please sign in to comment.