mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
Revert "chore: migrate away from ps1 in install-deps on Windows (#9876)"
This reverts commit 59a406a586de5cbe39ce092b591c2c2271936f1c.
This commit is contained in:
parent
cea61691fa
commit
dd1d3c3ed9
5
packages/playwright-core/bin/install_media_pack.ps1
Normal file
5
packages/playwright-core/bin/install_media_pack.ps1
Normal file
@ -0,0 +1,5 @@
|
||||
$osInfo = Get-WmiObject -Class Win32_OperatingSystem
|
||||
# check if running on Windows Server
|
||||
if ($osInfo.ProductType -eq 3) {
|
||||
Install-WindowsFeature Server-Media-Foundation
|
||||
}
|
@ -22,6 +22,8 @@ import { getUbuntuVersion } from './ubuntuVersion';
|
||||
import * as utils from './utils';
|
||||
import { buildPlaywrightCLICommand } from './registry';
|
||||
|
||||
const BIN_DIRECTORY = path.join(__dirname, '..', '..', 'bin');
|
||||
|
||||
const checkExecutable = (filePath: string) => fs.promises.access(filePath, fs.constants.X_OK).then(() => true).catch(e => false);
|
||||
|
||||
function isSupportedWindowsVersion(): boolean {
|
||||
@ -37,33 +39,11 @@ function isSupportedWindowsVersion(): boolean {
|
||||
export type DependencyGroup = 'chromium' | 'firefox' | 'webkit' | 'tools';
|
||||
|
||||
export async function installDependenciesWindows(targets: Set<DependencyGroup>) {
|
||||
if (!targets.has('chromium'))
|
||||
return;
|
||||
if (!await isWindowsServer())
|
||||
return;
|
||||
const { code } = await utils.spawnAsync('dism.exe', ['/Online', '/Enable-Feature', '/FeatureName:ServerMediaFoundation', '/Quiet'], { stdio: 'inherit' });
|
||||
if (code !== 0)
|
||||
throw new Error('Failed to install windows dependencies!');
|
||||
}
|
||||
|
||||
async function isWindowsServer(): Promise<boolean> {
|
||||
/**
|
||||
* ProductType Enum:
|
||||
* 0 = Unknown - Product type is unknown
|
||||
* 1 = WorkStation - System is a workstation
|
||||
* 2 = DomainController - System is a domain controller
|
||||
* 3 = Server - System is a server
|
||||
* @see https://docs.microsoft.com/en-us/dotnet/api/microsoft.powershell.commands.producttype?view=powershellsdk-1.1.0
|
||||
*/
|
||||
const { code, stdout } = await utils.spawnAsync('wmic.exe', ['path', 'Win32_OperatingSystem', 'get', 'ProductType', '/VALUE']);
|
||||
if (code !== 0)
|
||||
throw new Error('Failed to get product type version!');
|
||||
for (const line of stdout.trim().split('\n')) {
|
||||
const [key, value] = line.split('=');
|
||||
if (key === 'ProductType')
|
||||
return parseInt(value, 10) === 3;
|
||||
if (targets.has('chromium')) {
|
||||
const { code } = await utils.spawnAsync('powershell.exe', ['-File', path.join(BIN_DIRECTORY, 'install_media_pack.ps1')], { cwd: BIN_DIRECTORY, stdio: 'inherit' });
|
||||
if (code !== 0)
|
||||
throw new Error('Failed to install windows dependencies!');
|
||||
}
|
||||
throw new Error('Failed to parse product type version!\nstdout:' + stdout);
|
||||
}
|
||||
|
||||
export async function installDependenciesLinux(targets: Set<DependencyGroup>) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user