From ab6be5a42627f19dc36e57b548592a5e52cece4a Mon Sep 17 00:00:00 2001 From: Yasser Tahiri Date: Tue, 12 Nov 2024 23:50:23 +0100 Subject: [PATCH] :bug: Fix Windows path handling in `createVenv` function (#99) * :bug: Fix Windows path handling in `createVenv` function * :bug: Fix Windows environment variable handling in `createVenv` --- dist/index.js | 9 +++++++++ src/venv.ts | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/dist/index.js b/dist/index.js index 4511843..601aa71 100644 --- a/dist/index.js +++ b/dist/index.js @@ -66934,7 +66934,16 @@ exports.activateVenv = activateVenv; const exec_1 = __nccwpck_require__(1514); const core_1 = __nccwpck_require__(2186); const os_1 = __importDefault(__nccwpck_require__(2037)); +const path_1 = __importDefault(__nccwpck_require__(1017)); +const uvBinPath = path_1.default.join(os_1.default.homedir(), '.local', 'bin'); async function createVenv(venv) { + if (os_1.default.platform() === 'win32') { + await (0, exec_1.exec)('powershell', [ + '-Command', + `$env:Path = "${uvBinPath};$env:Path"` + ]); + } + (0, core_1.addPath)(uvBinPath); await (0, exec_1.exec)('uv', ['venv', venv]); } async function activateVenv(venv) { diff --git a/src/venv.ts b/src/venv.ts index 7e68701..030f7d8 100644 --- a/src/venv.ts +++ b/src/venv.ts @@ -1,8 +1,19 @@ import { exec } from '@actions/exec' import { exportVariable, addPath } from '@actions/core' import os from 'os' +import path from 'path' + +const uvBinPath = path.join(os.homedir(), '.local', 'bin') export async function createVenv(venv: string) { + if (os.platform() === 'win32') { + await exec('powershell', [ + '-Command', + `$env:Path = "${uvBinPath};$env:Path"` + ]) + } + addPath(uvBinPath) + await exec('uv', ['venv', venv]) }