Skip to content

Instantly share code, notes, and snippets.

@chirag64
Forked from jfromaniello/continous-qunit.ps1
Last active August 29, 2015 14:22
Show Gist options
  • Save chirag64/b726c3fccc67b3c10c12 to your computer and use it in GitHub Desktop.
Save chirag64/b726c3fccc67b3c10c12 to your computer and use it in GitHub Desktop.
# Watch a file changes in the current directory,
# Execute all tests when a file is changed or renamed
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = Get-Location
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $false
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite -bor [System.IO.NotifyFilters]::FileName
while($true)
{
$result = $watcher.WaitForChanged([System.IO.WatcherChangeTypes]::All, 1000);
if($result.TimedOut){
continue;
}
if ($result.ChangeType -eq "Renamed")
{
Write-Host $(Get-Date -Form "HH:mm:ss") "-" $result.ChangeType "file" $result.OldName "to" $result.Name
}
else
{
Write-Host $(Get-Date -Form "HH:mm:ss") "-" $result.ChangeType "file" $result.Name
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment