get-node
Version:
Download a specific version of Node.js
23 lines (16 loc) • 562 B
JavaScript
import{platform}from"node:process";
import{pipeline}from"node:stream/promises";
import{createGunzip}from"node:zlib";
import{fetchNodeUrl,promiseOrFetchError}from"../fetch.js";
import{moveTar,untar}from"./tar.js";
export const downloadGz=async({version,arch,tmpFile,fetchOpts})=>{
const{response,checksumError}=await fetchNodeUrl(
version,
`node-v${version}-${platform}-${arch}.tar.gz`,
fetchOpts
);
const promise=pipeline(response,createGunzip(),untar(tmpFile));
await promiseOrFetchError(promise,response);
await moveTar(tmpFile);
return checksumError
};