e2e-test: update yarnrc logic

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2022-08-22 13:44:33 +02:00
parent 0f98194fba
commit 1036a04ea8
+9 -6
View File
@@ -183,20 +183,23 @@ async function buildDistWorkspace(workspaceName: string, rootDir: string) {
* Pin the yarn version in a directory to the one we're using in the Backstage repo
*/
async function pinYarnVersion(dir: string) {
const yarnRc = await fs.readFile(paths.resolveOwnRoot('.yarnrc'), 'utf8');
const yarnRc = await fs.readFile(paths.resolveOwnRoot('.yarnrc.yml'), 'utf8');
const yarnRcLines = yarnRc.split('\n');
const yarnPathLine = yarnRcLines.find(line => line.startsWith('yarn-path'));
const yarnPathLine = yarnRcLines.find(line => line.startsWith('yarnPath:'));
if (!yarnPathLine) {
throw new Error(`Unable to find 'yarn-path' in ${yarnRc}`);
throw new Error(`Unable to find 'yarnPath' in ${yarnRc}`);
}
const match = yarnPathLine.match(/"(.*)"/);
const match = yarnPathLine.match(/^yarnPath: (.*)$/);
if (!match) {
throw new Error(`Invalid 'yarn-path' in ${yarnRc}`);
throw new Error(`Invalid 'yarnPath' in ${yarnRc}`);
}
const [, localYarnPath] = match;
const yarnPath = paths.resolveOwnRoot(localYarnPath);
await fs.writeFile(resolvePath(dir, '.yarnrc'), `yarn-path "${yarnPath}"\n`);
await fs.writeFile(
resolvePath(dir, '.yarnrc.yml'),
`yarnPath: ${yarnPath}\n`,
);
}
/**