generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvenv.ts
29 lines (25 loc) · 778 Bytes
/
venv.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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])
}
export async function activateVenv(venv: string) {
if (os.platform() === 'win32') {
await exec('powershell', [`${venv}\\Scripts\\activate.ps1`])
addPath(`${venv}/Scripts`)
} else {
await exec('/bin/bash', ['-c', `source ${venv}/bin/activate`])
addPath(`${venv}/bin`)
}
exportVariable('VIRTUAL_ENV', venv)
}