forked from ganeshrvel/openmtp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckYarn.js
27 lines (21 loc) · 928 Bytes
/
CheckYarn.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
const { execSync } = require('child_process');
const { semverSatisfies } = require('./semver');
const requiredVersionRange = '>=6.x <=8.16.0';
try {
const npmVersion = execSync('npm -v').toString().trim();
if (!semverSatisfies(npmVersion, requiredVersionRange)) {
console.error(
`Error: This project requires npm version ${requiredVersionRange}. You have version ${npmVersion}.\nPlease downgrade your npm, this is due to a bug in node-gyp. Github issue: https://github.com/ganeshrvel/openmtp/issues/367.\ncommand: npm install -g [email protected]`
);
process.exit(1);
}
console.info(`Using compatible npm version: ${npmVersion}`);
} catch (error) {
console.error('Error checking npm version:', error);
process.exit(1);
}
if (!/yarn\.js$/.test(process.env.npm_execpath || '')) {
console.warn(
"\u001b[33mYou don't seem to be using yarn. This could produce unexpected results.\u001b[39m"
);
}