Skip to content

Instantly share code, notes, and snippets.

@colonelpopcorn
Last active May 9, 2018 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colonelpopcorn/890afef2327c647afa16d38c0d239387 to your computer and use it in GitHub Desktop.
Save colonelpopcorn/890afef2327c647afa16d38c0d239387 to your computer and use it in GitHub Desktop.
# https://stackoverflow.com/questions/12319382/file-system-watcher-event-when-run-using-a-script#12323930
$watcher = new-object System.IO.FileSystemWatcher
$watcher.Path = '.\'
$watcher.Filter = '*.js' # whatever you need
#$watcher.IncludeSubDirectories = $true # if needed
$watcher.EnableRaisingEvents = $true
Register-ObjectEvent $watcher -EventName Changed -SourceIdentifier 'Watcher' -Action { param($sender, $eventArgs)
Write-Host "Detected change in files copying...";
# code to run copy/build script here
Write-Host "Done copying...";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment