Skip to content
Snippets Groups Projects
Unverified Commit fac38a1d authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

feat(npm): dynamic npm version install (#6415)

Closes #6360
parent a0b23148
No related branches found
No related tags found
No related merge requests found
......@@ -166,7 +166,7 @@ describe('generateLockFile', () => {
'some-dir',
{},
'package-lock.json',
{ binarySource: BinarySource.Docker }
{ binarySource: BinarySource.Docker, compatibility: { npm: '^6.0.0' } }
);
expect(fs.readFile).toHaveBeenCalledTimes(1);
expect(res.lockFile).toEqual('package-lock-contents');
......
import { move, pathExists, readFile } from 'fs-extra';
import { validRange } from 'semver';
import { quote } from 'shlex';
import { join } from 'upath';
import { SYSTEM_INSUFFICIENT_DISK_SPACE } from '../../../constants/error-messages';
import { logger } from '../../../logger';
......@@ -24,7 +26,12 @@ export async function generateLockFile(
let lockFile = null;
try {
const preCommands = ['npm i -g npm'];
let installNpm = 'npm i -g npm';
const npmCompatibility = config.compatibility?.npm;
if (validRange(npmCompatibility)) {
installNpm += `@${quote(npmCompatibility)}`;
}
const preCommands = [installNpm];
const commands = [];
let cmdOptions = '';
if (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment