Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support yarn & pnpm for generating new projects #283

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@
"type": "boolean",
"default": false,
"description": "Show & reuse browser between tests."
},
"playwright.packageManager": {
"type": "string",
"enum": ["npm", "yarn", "pnpm"],
"default": "npm",
"description": "Set yarn or pnpm. Default is npm."
},
"playwright.quiet": {
"type": "boolean",
"default": true,
"description": "Set --quiet for install"
}
}
},
Expand Down
18 changes: 17 additions & 1 deletion src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,23 @@ export async function installPlaywright(vscode: vscodeTypes.VSCode) {
if (result.includes(installDepsItem))
args.push('--install-deps');

terminal.sendText(`npm init playwright@latest --yes -- --quiet ${args.join(' ')}`, true);
// confirm package manager
const tool = await vscode.workspace.getConfiguration('playwright').get('packageManager');
const quiet = await vscode.workspace.getConfiguration('playwright').get('quiet');

switch (tool) {
case 'npm':
terminal.sendText(`npm init playwright@latest --yes -- ${quiet ? '--quiet' : ''} ${args.join(' ')}`, true);
break;
case 'yarn':
terminal.sendText(`yarn create playwright ${quiet ? '--quiet' : ''} ${args.join(' ')}`, true);
break;
case 'pnpm':
terminal.sendText(`pnpm dlx create-playwright ${quiet ? '--quiet' : ''} ${args.join(' ')}`, true);
break;
}

// terminal.sendText(`npm init playwright@latest --yes -- --quiet ${args.join(' ')}`, true);
}

export async function installBrowsers(vscode: vscodeTypes.VSCode, model: TestModel) {
Expand Down