Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { describe, expect, it } from 'vitest';
import path from 'node:path';
import { yarn } from '../yarn';
import { isYarnInstalled, yarn } from '../yarn';

describe('Yarn Package Management Utils', () => {
const shouldSkip = !(await isYarnInstalled());

describe.skipIf(shouldSkip)('Yarn Package Management Utils', () => {
describe('listDependencies', () => {
const cwd = path.resolve(__dirname, 'fixtures/simple-yarn-project');

Expand Down
9 changes: 9 additions & 0 deletions packages/wxt/src/core/package-managers/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { WxtPackageManagerImpl } from './types';
import { dedupeDependencies, npm } from './npm';
import spawn from 'nano-spawn';

export async function isYarnInstalled(): Promise<boolean> {
try {
await spawn('yarn', ['--version']);
return true;
} catch {
return false;
}
}

export const yarn: WxtPackageManagerImpl = {
overridesKey: 'resolutions',
downloadDependency(...args) {
Expand Down