Created
September 2, 2015 08:00
-
-
Save sayedihashimi/f10833014ddd4c766299 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Get-ScriptDirectory{ | |
| split-path (((Get-Variable MyInvocation -Scope 1).Value).MyCommand.Path) | |
| } | |
| $scriptDir = ((Get-ScriptDirectory) + "\") | |
| Add-Type -Path (Join-Path $scriptDir 'bin\Geoffry.Watch.dll') | |
| $watcherdef = New-Object -TypeName 'Geoffry.Watch.WatchDefinition' | |
| $watcherdef.GlobbingPattern = '**/*.css' | |
| $watcherdef.RootDirectory = (Join-Path $scriptDir 'src\css') | |
| 'Using pattern [{0}] to watch folder [{1}]' -f ($watcherdef.GlobbingPattern), ($watcherdef.RootDirectory) | Write-Host | |
| $timeout = [System.TimeSpan]::FromMilliseconds(500) | |
| $watchertype = [Geoffry.Watch.Watcher] | |
| Register-ObjectEvent -InputObject $watchertype -EventName Changed -Action { Write-Host 'changed';('changed {0}' -f [DateTime]::Now.ToLongTimeString())|Out-File M:\temp\foo-test.txt -Append } | |
| [Geoffry.Watch.WatchDefinition[]]$watchlist = @($watcherdef) | |
| $global:token = [Geoffry.Watch.Watcher]::Subscribe($timeout, $watchlist) | |
| #[Geoffry.Watch.Watcher]::Cancel($token) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment