Skip to content
Snippets Groups Projects
Commit 9f30c114 authored by Rhys Arkins's avatar Rhys Arkins
Browse files

feat(yarn): dynamic version selection

Closes #6281
parent 2e0e69c9
Branches
Tags
No related merge requests found
...@@ -40,6 +40,9 @@ describe(getName(__filename), () => { ...@@ -40,6 +40,9 @@ describe(getName(__filename), () => {
fs.readFile.mockResolvedValue('package-lock-contents' as never); fs.readFile.mockResolvedValue('package-lock-contents' as never);
const config = { const config = {
dockerMapDotfiles: true, dockerMapDotfiles: true,
compatibility: {
yarn: '^1.10.0',
},
postUpdateOptions: ['yarnDedupeFewer', 'yarnDedupeHighest'], postUpdateOptions: ['yarnDedupeFewer', 'yarnDedupeHighest'],
}; };
const res = await yarnHelper.generateLockFile('some-dir', {}, config); const res = await yarnHelper.generateLockFile('some-dir', {}, config);
......
import is from '@sindresorhus/is'; import is from '@sindresorhus/is';
import { readFile } from 'fs-extra'; import { readFile } from 'fs-extra';
import { validRange } from 'semver';
import { quote } from 'shlex';
import { join } from 'upath'; import { join } from 'upath';
import { SYSTEM_INSUFFICIENT_DISK_SPACE } from '../../../constants/error-messages'; import { SYSTEM_INSUFFICIENT_DISK_SPACE } from '../../../constants/error-messages';
import { DatasourceError } from '../../../datasource'; import { DatasourceError } from '../../../datasource';
...@@ -43,7 +45,12 @@ export async function generateLockFile( ...@@ -43,7 +45,12 @@ export async function generateLockFile(
logger.debug(`Spawning yarn install to create ${cwd}/yarn.lock`); logger.debug(`Spawning yarn install to create ${cwd}/yarn.lock`);
let lockFile = null; let lockFile = null;
try { try {
const preCommands = ['npm i -g yarn']; let installYarn = 'npm i -g npm';
const yarnCompatibility = config.compatibility?.yarn;
if (validRange(yarnCompatibility)) {
installYarn += `@${quote(yarnCompatibility)}`;
}
const preCommands = [installYarn];
if ( if (
config.skipInstalls !== false && config.skipInstalls !== false &&
(await hasYarnOfflineMirror(cwd)) === false (await hasYarnOfflineMirror(cwd)) === false
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment