-
-
Save GraemeF/1272979 to your computer and use it in GitHub Desktop.
Continuously watches for .coffee file changes in a folder (and subfolders), and runs the CoffeeScript compiler against them
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
# watch a file changes in the current directory, | |
# compile when a .coffee 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]::Changed -bor [System.IO.WatcherChangeTypes]::Renamed -bOr [System.IO.WatcherChangeTypes]::Created, 1000); | |
if($result.TimedOut){ | |
continue; | |
} | |
write-host "Modified" $result.Name | |
$file = Get-Item $result.Name | |
if($file.Extension -eq ".coffee"){ | |
write-host "Compiling" $result.Name | |
coffee.cmd -c $file.FullName | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note:
coffee.cmd
runs https://github.com/alisey/CoffeeScript-Compiler-for-Windows on my box but this works equally well with Node.exe if you'd like to use it to run the CoffeeScript compiler.