11$script :ModuleRoot = " $PSScriptRoot "
22$script :ModuleVersion = (Import-PowerShellDataFile - Path " $ ( $script :ModuleRoot ) \fscps.lcs.psd1" ).ModuleVersion
33$Script :DefaultTempPath = " c:\temp\fscps.lcs"
4- $Script :BinFolder = " $ ( $Script :ModuleRoot ) \bin"
5- $Script :PlaywrightDll = " $ ( $Script :BinFolder ) \Microsoft.Playwright.dll"
6- $Script :CookiesPath = " $Script :BinFolder \.playwright\state.json"
7-
84# Detect whether at some level dotsourcing was enforced
95$script :doDotSource = Get-PSFConfigValue - FullName fscps.lcs.Import.DoDotSource - Fallback $false
106if ($fscps.lcs_dotsourcemodule ) { $script :doDotSource = $true }
8884 . Import-ModuleFile - Path " $ ( $script :ModuleRoot ) \resourcesAfter.ps1"
8985 }
9086}
87+ $Script :BinFolder = " $ ( $Script :ModuleRoot ) \bin"
88+ $Script :PlaywrightDll = " $ ( $Script :BinFolder ) \Microsoft.Playwright.dll"
89+ $Script :CookiesPath = " $Script :BinFolder \.playwright\state.json"
9190
92- function Ensure-PlaywrightBrowsers {
93- # Check for the .playwright folder or a marker file to avoid redundant installs
94- $browsersMarker = Join-Path $Script :BinFolder " .playwright"
95- if (-not (Test-Path $browsersMarker )) {
96- Write-Verbose " Installing Playwright browsers..."
97- $Env: PLAYWRIGHT_DRIVER_SEARCH_PATH = " $Script :BinFolder "
98- $arguments = @ (" install" , " --with-deps" )
99- [Microsoft.Playwright.Program ]::Main($arguments )
100- } else {
101- Write-Verbose " Playwright browsers already installed."
102- }
103- }
10491# region Playwright
10592$tempFolder = [System.IO.Path ]::Combine($Script :DefaultTempPath , " Microsoft.Playwright" )
10693[System.IO.Directory ]::CreateDirectory($Script :tempFolder ) | Out-Null
@@ -120,11 +107,16 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem
120107
121108Get-ChildItem $tempFolder - Recurse | Where-Object { $_.Name -eq " Microsoft.Playwright.dll" } | ForEach-Object {
122109 $dllPath = $_.FullName
123- Copy-Item - Path $dllPath - Destination " $ ( $script :PlaywrightDll ) " - Force
110+ Copy-Item - Path $dllPath - Destination " $ ( $script :PlaywrightDll ) " - Force
124111 [Reflection.Assembly ]::Load([System.IO.File ]::ReadAllBytes(" $ ( $script :PlaywrightDll ) " )) | Out-Null
125112}
126- # Ensure Playwright browsers are installed
127- Ensure- PlaywrightBrowsers
113+ # Load the Playwright library
114+ $Env: PLAYWRIGHT_DRIVER_SEARCH_PATH = " $script :BinFolder "
115+ $arguments = @ (
116+ " install" ,
117+ " --with-deps"
118+ )
119+ [Microsoft.Playwright.Program ]::Main($arguments )
128120# endregion Playwright
129121
130122# endregion Load individual files
0 commit comments