UNPKG

get-node

Version:

Download a specific version of Node.js

21 lines (11 loc) 450 B
import{rename,rm}from"node:fs/promises"; import{extract as tarExtract}from"tar-fs"; export const untar=(tmpFile)=> tarExtract(tmpFile,{ignore:shouldExclude,strip:2}); const shouldExclude=(path)=>!path.endsWith("/node"); export const moveTar=async(tmpFile)=>{ const intermediateFile=`${tmpFile}-${Math.random()}`; await rename(`${tmpFile}/node`,intermediateFile); await rm(tmpFile,{recursive:true}); await rename(intermediateFile,tmpFile) };