-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstaller.js
More file actions
26 lines (21 loc) · 799 Bytes
/
Copy pathinstaller.js
File metadata and controls
26 lines (21 loc) · 799 Bytes
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
const path = require("path")
const core = require("@actions/core")
const tools = require("@actions/tool-cache")
const TOOL_NAME = "nodenv"
module.exports = {
installNodenv: async function (version) {
const toolPath = tools.find(TOOL_NAME, version) || downloadNodenv(version)
// prepend bin directory to PATH for future tasks
core.addPath(path.join(await toolPath, "bin"))
return toolPath
}
}
async function downloadNodenv(version) {
return Promise.resolve(
`https://github.com/nodenv/nodenv/archive/v${version}.tar.gz`
)
.then((url) => tools.downloadTool(url))
.then((tarballPath) => tools.extractTar(tarballPath))
.then((extractedPath) => `${extractedPath}/nodenv-${version}`)
.then((nodenvPath) => tools.cacheDir(nodenvPath, TOOL_NAME, version))
}