-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtasks.js
More file actions
25 lines (18 loc) · 795 Bytes
/
tasks.js
File metadata and controls
25 lines (18 loc) · 795 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
import {info} from '@travi/cli-messages';
import {execa} from 'execa';
export async function determineLatestVersionOf(nodeVersionCategory) {
info('Determining version of node', {level: 'secondary'});
const {stdout: nvmLsOutput} = await execa(
`. ~/.nvm/nvm.sh && nvm ls-remote${('LTS' === nodeVersionCategory) ? ' --lts' : ''}`,
{shell: true}
);
const lsLines = nvmLsOutput.split('\n');
const lsLine = lsLines[lsLines.length - 2];
return lsLine.match(/(v[0-9]+)\.[0-9]+\.[0-9]+/)[1];
}
export function install(nodeVersionCategory) {
info(`Installing ${nodeVersionCategory} version of node using nvm`, {level: 'secondary'});
const subprocess = execa('. ~/.nvm/nvm.sh && nvm install', {shell: true});
subprocess.stdout.pipe(process.stdout);
return subprocess;
}