Skip to content

Instantly share code, notes, and snippets.

@stianl
Forked from jfromaniello/continous-qunit.ps1
Created October 16, 2012 13:53
Show Gist options
  • Save stianl/3899418 to your computer and use it in GitHub Desktop.
Save stianl/3899418 to your computer and use it in GitHub Desktop.
Since less doesn't include a --watch option, and the only options I found was with ruby watchr+shell scripting I modified this Powershell script that continuously watch for file changes in a directory, and compiles less file
# watch a file changes in the current directory,
# compiles bootstrap.less
$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 "Change in " + $result.Name
lessc --compress bootstrap.less > ..\..\public\bootstrap\css\bootstrap.min.css
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment