-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtools.js
53 lines (49 loc) · 1.13 KB
/
tools.js
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const { execSync } = require("child_process");
module.exports = {
node: {
getVersion: "node --version",
getInstallInstructions(v) {
if (hasNvm()) {
return `To install node, run \`nvm install ${v}\``;
}
return `To install node, see https://nodejs.org/download/release/v${v}/`;
}
},
npm: {
getVersion: "npm --version",
getInstallInstructions(v) {
return `To install npm, run \`npm install -g npm@${v}\``;
}
},
npx: {
getVersion: "npx --version",
getInstallInstructions(v) {
return `To install npx, run \`npm install -g npx@${v}\``;
}
},
yarn: {
getVersion: "yarn --version",
getInstallInstructions(v) {
return `To install yarn, see https://github.com/yarnpkg/yarn/releases/tag/v${v}`;
}
},
pnpm: {
getVersion: "pnpm --version",
getInstallInstructions(v) {
return `To install pnpm, run \`npm install -g pnpm@${v}\``;
}
},
};
function hasNvm() {
try {
// check for existance of nvm
execSync(
'nvm',
{ stdio:[] } // don't care about output
);
} catch (e) {
// no nvm,
return false;
}
return true;
}