Skip to content

Commit

Permalink
feat: Attempt to use yarn berry when yarn is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Mar 27, 2023
1 parent 0532571 commit 24aaa62
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/generator-js/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,23 @@ export class BetterGenerator<
// we're overriding a private member
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const before = this.env.detectPackageManager;
const superDetectPackageManager = this.env.detectPackageManager;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
this.env.detectPackageManager = async function () {
const name = await before.call(this);
const name = await superDetectPackageManager.call(this);
// use yarn if installed.
// if someone installed yarn they probably mean to use it on any new projects.
if (!name) {
try {
await execa('which', ['yarn'], { shell: true });

try {
await execa(`yarn`, ['set version berry'], {
shell: true,
});
} catch (e) {}

return 'yarn';
// eslint-disable-next-line no-empty
} catch (e) {}
Expand Down

0 comments on commit 24aaa62

Please sign in to comment.