-
-
Notifications
You must be signed in to change notification settings - Fork 552
Expand file tree
/
Copy pathget-node-nightly.ts
More file actions
executable file
·27 lines (24 loc) · 1019 Bytes
/
get-node-nightly.ts
File metadata and controls
executable file
·27 lines (24 loc) · 1019 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
27
#!/usr/bin/env -S ts-node --esm --transpileOnly
import { existsSync, mkdirSync } from 'fs';
import { unlinkSync, rmdirSync } from 'fs';
import { dirname, resolve } from 'path';
import { $ } from '@cspotcode/zx';
async function main() {
const __root = dirname(__dirname);
const downloadDir = resolve(__root, 'temp/node-nightly');
const result = await fetch('https://nodejs.org/download/nightly/index.json');
const index = await result.json();
const latest = index[0];
const { version } = latest;
existsSync(downloadDir) && rmdirSync(downloadDir, { recursive: true });
mkdirSync(downloadDir, { recursive: true });
await $`wget -O ${downloadDir}/download.tar.gz https://nodejs.org/download/nightly/${version}/node-${version}-linux-x64.tar.gz`;
process.chdir(downloadDir);
await $`tar -xzvf ${downloadDir}/download.tar.gz node-${version}-linux-x64/bin/node`;
console.log(``);
console.log(
`export PATH="${downloadDir}/node-${version}-linux-x64/bin:$PATH"`
);
console.log(``);
}
main();