mirror of
https://gitea.com/actions/setup-deno.git
synced 2025-12-13 11:56:58 +00:00
feat: allow specifying binary name (#71)
This commit is contained in:
16
.github/workflows/test.yml
vendored
16
.github/workflows/test.yml
vendored
@@ -61,3 +61,19 @@ jobs:
|
|||||||
|
|
||||||
- name: Check version
|
- name: Check version
|
||||||
run: deno -V | grep -q "deno 1\.43\.1"
|
run: deno -V | grep -q "deno 1\.43\.1"
|
||||||
|
|
||||||
|
test-binary-name:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Deno
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
deno-binary-name: deno_foo
|
||||||
|
|
||||||
|
- name: Check binary exists
|
||||||
|
run: deno_foo -V
|
||||||
|
|||||||
@@ -73,3 +73,11 @@ The extension can also automatically read the file from
|
|||||||
with:
|
with:
|
||||||
deno-version-file: .dvmrc
|
deno-version-file: .dvmrc
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Specifying binary name
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- uses: denoland/setup-deno@v1
|
||||||
|
with:
|
||||||
|
deno-binary-name: deno_latest
|
||||||
|
```
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ inputs:
|
|||||||
default: "1.x"
|
default: "1.x"
|
||||||
deno-version-file:
|
deno-version-file:
|
||||||
description: File containing the Deno version to install such as .dvmrc or .tool-versions.
|
description: File containing the Deno version to install such as .dvmrc or .tool-versions.
|
||||||
|
deno-binary-name:
|
||||||
|
description: The name to use for the binary.
|
||||||
|
default: "deno"
|
||||||
outputs:
|
outputs:
|
||||||
deno-version:
|
deno-version:
|
||||||
description: "The Deno version that was installed."
|
description: "The Deno version that was installed."
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const os = require("os");
|
const os = require("os");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
const fs = require("fs/promises");
|
||||||
const process = require("process");
|
const process = require("process");
|
||||||
const core = require("@actions/core");
|
const core = require("@actions/core");
|
||||||
const tc = require("@actions/tool-cache");
|
const tc = require("@actions/tool-cache");
|
||||||
@@ -28,9 +29,23 @@ async function install(version) {
|
|||||||
const zipPath = await tc.downloadTool(url);
|
const zipPath = await tc.downloadTool(url);
|
||||||
const extractedFolder = await tc.extractZip(zipPath);
|
const extractedFolder = await tc.extractZip(zipPath);
|
||||||
|
|
||||||
|
const binaryName = core.getInput("deno-binary-name");
|
||||||
|
if (binaryName !== "deno") {
|
||||||
|
await fs.rename(
|
||||||
|
path.join(
|
||||||
|
extractedFolder,
|
||||||
|
process.platform === "win32" ? "deno.exe" : "deno",
|
||||||
|
),
|
||||||
|
path.join(
|
||||||
|
extractedFolder,
|
||||||
|
process.platform === "win32" ? binaryName + ".exe" : binaryName,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const newCachedPath = await tc.cacheDir(
|
const newCachedPath = await tc.cacheDir(
|
||||||
extractedFolder,
|
extractedFolder,
|
||||||
"deno",
|
binaryName,
|
||||||
version.isCanary ? `0.0.0-${version.version}` : version.version,
|
version.isCanary ? `0.0.0-${version.version}` : version.version,
|
||||||
);
|
);
|
||||||
core.info(`Cached Deno to ${newCachedPath}.`);
|
core.info(`Cached Deno to ${newCachedPath}.`);
|
||||||
|
|||||||
Reference in New Issue
Block a user