File tree Expand file tree Collapse file tree 2 files changed +33
-7
lines changed
schematics/install-browsers Expand file tree Collapse file tree 2 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,17 @@ async function startDevServer(
6262 return server ;
6363}
6464
65+ export function getPackageManagerExecCommand ( ) {
66+ const env = process . env . npm_config_user_agent || '' ;
67+ if ( env . includes ( 'yarn' ) ) {
68+ return 'yarn' ;
69+ }
70+ if ( env . includes ( 'pnpm' ) ) {
71+ return 'pnpm exec' ;
72+ }
73+ return 'npx' ;
74+ }
75+
6576async function startPlaywrightTest ( options : JsonObject , baseURL : string ) {
6677 // PLAYWRIGHT_TEST_BASE_URL is actually a non-documented env variable used
6778 // by Playwright Test.
@@ -75,12 +86,16 @@ async function startPlaywrightTest(options: JsonObject, baseURL: string) {
7586 }
7687
7788 return new Promise ( ( resolve , reject ) => {
78- const childProcess = spawn ( 'npx playwright test' , buildArgs ( options ) , {
79- cwd : process . cwd ( ) ,
80- stdio : 'inherit' ,
81- shell : true ,
82- env,
83- } ) ;
89+ const childProcess = spawn (
90+ `${ getPackageManagerExecCommand ( ) } playwright test` ,
91+ buildArgs ( options ) ,
92+ {
93+ cwd : process . cwd ( ) ,
94+ stdio : 'inherit' ,
95+ shell : true ,
96+ env,
97+ } ,
98+ ) ;
8499
85100 childProcess . on ( 'exit' , ( exitCode ) => {
86101 if ( exitCode !== 0 ) {
Original file line number Diff line number Diff line change 11import { spawnSync } from 'node:child_process' ;
22import type { Rule , SchematicContext , Tree } from '@angular-devkit/schematics' ;
33
4+ export function getPackageManagerExecCommand ( ) {
5+ const env = process . env . npm_config_user_agent || '' ;
6+ if ( env . includes ( 'yarn' ) ) {
7+ return 'yarn' ;
8+ }
9+ if ( env . includes ( 'pnpm' ) ) {
10+ return 'pnpm exec' ;
11+ }
12+ return 'npx' ;
13+ }
14+
415export default function installBrowsers ( ) : Rule {
516 return ( tree : Tree , context : SchematicContext ) => {
617 context . logger . info ( 'Installing browsers...' ) ;
718
8- spawnSync ( 'npx playwright install' , [ ] , {
19+ spawnSync ( ` ${ getPackageManagerExecCommand ( ) } playwright install` , [ ] , {
920 cwd : process . cwd ( ) ,
1021 stdio : 'inherit' ,
1122 shell : true ,
You can’t perform that action at this time.
0 commit comments