lib/vagrant-windows/scripts/cheftask.ps1.erb in vagrant-windows-1.3.0.pre.3 vs lib/vagrant-windows/scripts/cheftask.ps1.erb in vagrant-windows-1.3.0

- old
+ new

@@ -1,10 +1,7 @@ -schtasks /query /tn "chef-solo" | Out-Null -if ($?) { - # task already exists, kill it - schtasks /delete /tn "chef-solo" /f | Out-Null -} +# kill the task so we can recreate it +schtasks /delete /tn "chef-solo" /f 2>&1 | out-null # Ensure the chef task running file doesn't exist from a previous failure if (Test-Path "<%= options[:chef_task_running] %>") { del "<%= options[:chef_task_running] %>" } @@ -32,16 +29,20 @@ $numLinesRead = 0 $success = $TRUE while (Test-Path "<%= options[:chef_task_running] %>") { Start-Sleep -m 100 - $text = (get-content "<%= options[:chef_stdout_log] %>") - $numLines = ($text | Measure-Object -line).lines - $numLinesToRead = $numLines - $numLinesRead - - $text | select -first $numLinesToRead -skip $numLinesRead | ForEach { - Write-Host "$_" + if (Test-Path "<%= options[:chef_stdout_log] %>") { + $text = (get-content "<%= options[:chef_stdout_log] %>") + $numLines = ($text | Measure-Object -line).lines + $numLinesToRead = $numLines - $numLinesRead + + if ($numLinesToRead -gt 0) { + $text | select -first $numLinesToRead -skip $numLinesRead | ForEach { + Write-Host "$_" + } + $numLinesRead += $numLinesToRead + } } - $numLinesRead += $numLinesToRead } exit Get-Content "<%= options[:chef_task_exitcode] %>"