From 2b9e5df4cbf15049a7099e1ed95c7adea449d0f3 Mon Sep 17 00:00:00 2001 From: afirth Date: Tue, 23 Jul 2024 14:00:19 +0200 Subject: [PATCH] Support subdirectory for install action --- install/action.yml | 4 ++-- install/main.js | 5 +++++ src/install/index.ts | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/install/action.yml b/install/action.yml index cde0b21..b2f9c6f 100644 --- a/install/action.yml +++ b/install/action.yml @@ -6,11 +6,11 @@ runs: main: main.js inputs: tool_versions: - description: + description: |- If present, this value will be written to the .tool-versions file. required: false before_install: - description: + description: |- Bash script to run after plugins are installed but before `asdf install`. eg, to install npm keyring required: false diff --git a/install/main.js b/install/main.js index 5e1063d..09b3ada 100644 --- a/install/main.js +++ b/install/main.js @@ -3261,6 +3261,7 @@ var require_exec = __commonJS({ var core4 = __toESM(require_core()); // src/install/index.ts +var import_node_process = require("node:process"); var core3 = __toESM(require_core()); var exec5 = __toESM(require_exec()); @@ -3363,6 +3364,10 @@ async function pluginsAdd() { // src/install/index.ts async function toolsInstall() { + const dir = core3.getInput("directory", { required: false }); + if (dir) { + (0, import_node_process.chdir)(dir); + } await pluginsAdd(); const before = core3.getInput("before_install", { required: false }); if (before) { diff --git a/src/install/index.ts b/src/install/index.ts index 25ffe83..7f613bc 100644 --- a/src/install/index.ts +++ b/src/install/index.ts @@ -1,8 +1,14 @@ +import {chdir} from 'node:process'; import * as core from '@actions/core'; import * as exec from '@actions/exec'; import {pluginsAdd} from '~/plugins-add/index.ts'; async function toolsInstall(): Promise { + const dir = core.getInput('directory', {required: false}); + if (dir) { + chdir(dir); + } + await pluginsAdd(); const before = core.getInput('before_install', {required: false});