Skip to content
Snippets Groups Projects
Unverified Commit 06ae68fc authored by Niklas Logren's avatar Niklas Logren Committed by GitHub
Browse files

fix(npm): support frozen-lockfile in .yarnrc (#18184)

parent 5bdbadf2
No related branches found
No related tags found
No related merge requests found
......@@ -647,5 +647,17 @@ describe('modules/manager/npm/post-update/yarn', () => {
expect(yarnPath).toBeNull();
expect(Fixtures.toJSON()['/tmp/renovate/.yarnrc']).toBe('\n');
});
it('removes pure-lockfile and frozen-lockfile from .yarnrc', async () => {
Fixtures.mock(
{
'.yarnrc': `--install.pure-lockfile true\n--install.frozen-lockfile true\n`,
},
'/tmp/renovate'
);
GlobalConfig.set({ localDir: '/tmp/renovate', cacheDir: '/tmp/cache' });
await yarnHelper.checkYarnrc('/tmp/renovate');
expect(Fixtures.toJSON()['/tmp/renovate/.yarnrc']).toBe('\n\n');
});
});
});
......@@ -56,16 +56,22 @@ export async function checkYarnrc(
const yarnBinaryExists = yarnPath
? await localPathIsFile(yarnPath)
: false;
let scrubbedYarnrc = yarnrc
.replace('--install.pure-lockfile true', '')
.replace('--install.frozen-lockfile true', '');
if (!yarnBinaryExists) {
const scrubbedYarnrc = yarnrc.replace(
scrubbedYarnrc = scrubbedYarnrc.replace(
regEx(/^yarn-path\s+"?.+?"?$/gm),
''
);
yarnPath = null;
}
if (yarnrc !== scrubbedYarnrc) {
logger.debug(`Writing scrubbed .yarnrc to ${lockFileDir}`);
await writeLocalFile(
upath.join(lockFileDir, '.yarnrc'),
scrubbedYarnrc
);
yarnPath = null;
}
}
} catch (err) /* istanbul ignore next */ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment