Enforce yarn version (#162610)

* Enforce yarn version

Actually require >=1.10.1 and <2

* error when yarn >= 2
This commit is contained in:
Michael Rienstra 2022-10-05 05:22:33 -07:00 committed by GitHub
parent 7278d50cc7
commit 625fec97f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,12 +21,19 @@ const path = require('path');
const fs = require('fs');
const cp = require('child_process');
const yarnVersion = cp.execSync('yarn -v', { encoding: 'utf8' }).trim();
const parsedYarnVersion = /^(\d+)\.(\d+)\./.exec(yarnVersion);
const parsedYarnVersion = /^(\d+)\.(\d+)\.(\d+)/.exec(yarnVersion);
const majorYarnVersion = parseInt(parsedYarnVersion[1]);
const minorYarnVersion = parseInt(parsedYarnVersion[2]);
const patchYarnVersion = parseInt(parsedYarnVersion[3]);
if (majorYarnVersion < 1 || minorYarnVersion < 10) {
console.error('\033[1;31m*** Please use yarn >=1.10.1.\033[0;0m');
if (
majorYarnVersion < 1 ||
majorYarnVersion === 1 && (
minorYarnVersion < 10 || (minorYarnVersion === 10 && patchYarnVersion < 1)
) ||
majorYarnVersion >= 2
) {
console.error('\033[1;31m*** Please use yarn >=1.10.1 and <2.\033[0;0m');
err = true;
}