[remix] Only add workspace check flag for Yarn v1 (#10364)

Yarn v2/v3 do not require this flag.
This commit is contained in:
Nathan Rajlich
2023-08-17 12:17:28 -07:00
committed by GitHub
parent 6aa2dc6f51
commit 09174df6cf
2 changed files with 13 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
import semver from 'semver';
import { execSync } from 'child_process';
import { existsSync, promises as fs } from 'fs';
import { basename, dirname, join, relative, resolve, sep } from 'path';
import { pathToRegexp, Key } from 'path-to-regexp';
@@ -283,10 +284,16 @@ export function addDependencies(
}
} else {
// 'yarn'
args.push('add', '--ignore-workspace-root-check');
args.push('add');
if (opts.saveDev) {
args.push('--dev');
}
const yarnVersion = execSync('yarn -v', { encoding: 'utf8' }).trim();
const isYarnV1 = semver.satisfies(yarnVersion, '1');
if (isYarnV1) {
// Ignoring workspace check is only needed on Yarn v1
args.push('--ignore-workspace-root-check');
}
}
// Don't fail if pnpm is being run at the workspace root