@@ -38,15 +38,21 @@ function isSupportedWindowsVersion(): boolean {
3838
3939export type DependencyGroup = 'chromium' | 'firefox' | 'webkit' | 'tools' ;
4040
41- export async function installDependenciesWindows ( targets : Set < DependencyGroup > ) {
41+ export async function installDependenciesWindows ( targets : Set < DependencyGroup > , dryRun : boolean ) : Promise < void > {
4242 if ( targets . has ( 'chromium' ) ) {
43- const { code } = await utils . spawnAsync ( 'powershell.exe' , [ '-ExecutionPolicy' , 'Bypass' , '-File' , path . join ( BIN_DIRECTORY , 'install_media_pack.ps1' ) ] , { cwd : BIN_DIRECTORY , stdio : 'inherit' } ) ;
43+ const command = 'powershell.exe' ;
44+ const args = [ '-ExecutionPolicy' , 'Bypass' , '-File' , path . join ( BIN_DIRECTORY , 'install_media_pack.ps1' ) ] ;
45+ if ( dryRun ) {
46+ console . log ( `${ command } ${ quoteProcessArgs ( args ) . join ( ' ' ) } ` ) ; // eslint-disable-line no-console
47+ return ;
48+ }
49+ const { code } = await utils . spawnAsync ( command , args , { cwd : BIN_DIRECTORY , stdio : 'inherit' } ) ;
4450 if ( code !== 0 )
4551 throw new Error ( 'Failed to install windows dependencies!' ) ;
4652 }
4753}
4854
49- export async function installDependenciesLinux ( targets : Set < DependencyGroup > ) {
55+ export async function installDependenciesLinux ( targets : Set < DependencyGroup > , dryRun : boolean ) {
5056 const libraries : string [ ] = [ ] ;
5157 for ( const target of targets ) {
5258 const info = deps [ utils . hostPlatform ] ;
@@ -57,13 +63,18 @@ export async function installDependenciesLinux(targets: Set<DependencyGroup>) {
5763 libraries . push ( ...info [ target ] ) ;
5864 }
5965 const uniqueLibraries = Array . from ( new Set ( libraries ) ) ;
60- console . log ( 'Installing Ubuntu dependencies...' ) ; // eslint-disable-line no-console
66+ if ( ! dryRun )
67+ console . log ( 'Installing Ubuntu dependencies...' ) ; // eslint-disable-line no-console
6168 const commands : string [ ] = [ ] ;
6269 commands . push ( 'apt-get update' ) ;
6370 commands . push ( [ 'apt-get' , 'install' , '-y' , '--no-install-recommends' ,
6471 ...uniqueLibraries ,
6572 ] . join ( ' ' ) ) ;
6673 const [ command , args ] = await buildAptProcessArgs ( commands ) ;
74+ if ( dryRun ) {
75+ console . log ( `${ command } ${ quoteProcessArgs ( args ) . join ( ' ' ) } ` ) ; // eslint-disable-line no-console
76+ return ;
77+ }
6778 const child = childProcess . spawn ( command , args , { stdio : 'inherit' } ) ;
6879 await new Promise ( ( resolve , reject ) => {
6980 child . on ( 'exit' , resolve ) ;
@@ -293,3 +304,11 @@ const MANUAL_LIBRARY_TO_PACKAGE_NAME_UBUNTU: { [s: string]: string} = {
293304 // gstreamer1.0-libav -> libavcodec57 -> libx264-152
294305 'libx264.so' : 'gstreamer1.0-libav' ,
295306} ;
307+
308+ function quoteProcessArgs ( args : string [ ] ) : string [ ] {
309+ return args . map ( arg => {
310+ if ( arg . includes ( ' ' ) )
311+ return `"${ arg } "` ;
312+ return arg ;
313+ } ) ;
314+ }
0 commit comments