Skip to content

Commit

Permalink
repo-tools: verify yarn versions in generate-patch
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
  • Loading branch information
Rugvip committed Oct 24, 2024
1 parent b598f65 commit 709a054
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/repo-tools/src/commands/generate-patch/generate-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export default async (
);
}

await verifyYarnVersion(sourceRepo.root.dir);
await verifyYarnVersion(targetRepo.root.dir);

const sourcePkg = sourceRepo.packages.find(
pkg =>
pkg.packageJson.name === packageArg ||
Expand Down Expand Up @@ -221,6 +224,22 @@ async function loadTrimmedRootPkg(ctx: PatchContext, query?: string) {
};
}

// Verify that a repo is using a supported Yarn version
async function verifyYarnVersion(cwd: string) {
const { stdout } = await exec('yarn', ['--version'], {
cwd,
});
const version = stdout.toString('utf8').trim();

if (version.startsWith('1.')) {
throw new Error(
`Unsupported Yarn version in target repository, got ${stdout
.toString('utf8')
.trim()} but 2+ is required`,
);
}
}

// Generate a new patch and return the path to the generated patch file. Will
// instead return undefined if the patch is empty.
async function generatePatch(
Expand Down

0 comments on commit 709a054

Please sign in to comment.