Browse Source

Updated the "watch" task

main
Cédric Belin 2 weeks ago
parent
commit
71feb04b26
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      tool/watch.ps1

+ 8
- 6
tool/watch.ps1 View File

@@ -1,7 +1,6 @@
#!/usr/bin/env pwsh
Set-StrictMode -Version Latest
Set-Location (Split-Path $PSScriptRoot)
[Console]::TreatControlCAsInput = $true

$action = {
if ($EventArgs.Name -notlike "*.g.php") {
@@ -20,10 +19,13 @@ foreach ($event in "Changed", "Created", "Deleted", "Renamed") {
Register-ObjectEvent $watcher $event -Action $action | Out-Null
}

$console = $Host.UI.RawUI;
while ($true) {
if ($console.KeyAvailable -and ($console.ReadKey("AllowCtrlC,IncludeKeyUp,NoEcho").Character -eq 3)) { break }
Start-Sleep -Milliseconds 200
try {
composer run build
do { Wait-Event -Timeout 1 } while ($true)
}

Get-EventSubscriber | Unregister-Event
finally {
$watcher.EnableRaisingEvents = $false
$watcher.Dispose()
Get-EventSubscriber | Unregister-Event -Force
}

Loading…
Cancel
Save