Permalink
Browse files

Added warning when using the watch flag with a task that has no prere…

…quisites.
  • Loading branch information...
1 parent 2751db8 commit a6b25de127928850f0ea0a752d4f0d11cc03b491 @KrisJordan committed Jan 5, 2011
Showing with 7 additions and 1 deletion.
  1. +3 −0 docs/icing.html
  2. +4 −1 src/icing.coffee
View
@@ -111,6 +111,9 @@
<span class="k">if</span> <span class="nx">options</span><span class="p">.</span><span class="nx">watch</span><span class="o">?</span>
<span class="nv">fileSources = </span><span class="nx">graph</span><span class="p">.</span><span class="nx">fileSources</span><span class="p">(</span><span class="nx">target</span><span class="p">).</span><span class="nx">names</span><span class="p">()</span>
+ <span class="k">if</span> <span class="nx">fileSources</span><span class="p">.</span><span class="nx">length</span> <span class="o">==</span> <span class="mi">0</span>
+ <span class="nx">console</span><span class="p">.</span><span class="nx">error</span> <span class="nx">stylize</span> <span class="s2">&quot;Nothing to watch.&quot;</span><span class="p">,</span> <span class="s1">&#39;red&#39;</span>
+
<span class="nx">fileSources</span><span class="p">.</span><span class="nx">forEach</span> <span class="nf">(file) -&gt;</span>
<span class="nx">fs</span><span class="p">.</span><span class="nx">watchFile</span> <span class="nx">file</span><span class="p">,</span> <span class="p">{</span><span class="nx">interval</span><span class="o">:</span><span class="mi">250</span><span class="p">},</span> <span class="nf">(curr,prev) -&gt;</span>
<span class="k">if</span> <span class="nx">taskIsRunning</span> <span class="k">then</span> <span class="k">return</span>
View
@@ -118,12 +118,15 @@ global.task = (target, description, prereqs=undefined, recipe=undefined) ->
allRecipesProcessed = true
if not aRecipeRan and options.verbose?
# Homage
- console.log "cake: Nothing to be done for `#{target}'."
+ console.error stylize "cake: Nothing to be done for `#{target}'.", 'yellow'
taskIsRunning = false
do runNextRecipeCallback
if options.watch?
fileSources = graph.fileSources(target).names()
+ if fileSources.length == 0
+ console.error stylize "cake: Nothing to watch for `#{target}'", 'yellow'
+
fileSources.forEach (file) ->
fs.watchFile file, {interval:250}, (curr,prev) ->
if taskIsRunning then return

0 comments on commit a6b25de

Please sign in to comment.