Skip to content

Commit 9727e4b

Browse files
authored
Merge pull request #1391 from nrkno/chore/check-yarn-version
chore: add check to install-and-build script to disallow yarn 1
2 parents f06e76f + 929df95 commit 9727e4b

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

scripts/install-and-build.mjs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,41 @@
1+
import cp from "child_process";
12
import process from "process";
23
import concurrently from "concurrently";
34
import { EXTRA_PACKAGES, config } from "./lib.js";
45

56
function hr() {
67
// write regular dashes if this is a "simple" output stream ()
78
if (!process.stdout.hasColors || !process.stdout.hasColors())
8-
return '-'.repeat(process.stdout.columns ?? 40)
9-
return '─'.repeat(process.stdout.columns ?? 40)
9+
return "-".repeat(process.stdout.columns ?? 40);
10+
return "─".repeat(process.stdout.columns ?? 40);
11+
}
12+
function exec(cmd) {
13+
return new Promise((resolve, reject) => {
14+
cp.exec(cmd, (err, stdout, stderr) => {
15+
if (err) reject(err);
16+
resolve({ stdout, stderr });
17+
});
18+
});
19+
}
20+
const yarnVersion = await exec("yarn -v");
21+
22+
// Require yarn > 1:
23+
if (
24+
yarnVersion.stdout.startsWith("0.") ||
25+
yarnVersion.stdout.startsWith("1.")
26+
) {
27+
console.error(
28+
"It seems like you're using an old version of yarn. Please upgrade to yarn 2 or later"
29+
);
30+
console.error(`Detected yarn version: ${yarnVersion.stdout.trim()}`);
31+
console.error(`--`);
32+
console.error(`Tip:`);
33+
console.error(
34+
`To uninstall yarn classic, you can find where it's installed by running 'which yarn' or 'where yarn'`
35+
);
36+
console.error(`After you have uninstalled it, run 'corepack enable'`);
37+
38+
process.exit(1);
1039
}
1140

1241
try {
@@ -41,9 +70,9 @@ try {
4170
console.log(" 🪛 Build packages...");
4271
console.log(hr());
4372

44-
const buildArgs = ['--ignore @sofie-automation/webui']
73+
const buildArgs = ["--ignore @sofie-automation/webui"];
4574
if (config.uiOnly) {
46-
buildArgs.push(...EXTRA_PACKAGES.map((pkg) => `--ignore ${pkg}`))
75+
buildArgs.push(...EXTRA_PACKAGES.map((pkg) => `--ignore ${pkg}`));
4776
}
4877

4978
await concurrently(

0 commit comments

Comments
 (0)