Skip to content
Permalink
Browse files

fix(templateCache): fix the build from crashing when running template…

…Cache with no views
  • Loading branch information
jyounce committed Aug 21, 2015
1 parent 0b49215 commit e5882201920ef8c9cd1a1591037c0889cba5ce65
Showing with 23 additions and 3 deletions.
  1. +16 −1 helpers/dir.coffee
  2. +1 −1 tasks/clean/cleanup-client.coffee
  3. +6 −1 tasks/minify/template-cache.coffee
@@ -1,4 +1,5 @@
module.exports = (config) ->
module.exports = (config, gulp) ->
q = require 'q'
fs = require 'fs'
path = require 'path'
log = require "#{config.req.helpers}/log"
@@ -63,6 +64,20 @@ module.exports = (config) ->
_dirs.push _path if not flag

_dirs

# returns promise with hasFiles boolean value
hasFiles: (src) ->
defer = q.defer()
opts = buffer:false, read:false
hasFiles = false
gulp.src src, opts
.on 'data', (file) ->
return unless file
hasFiles = true
@.end()
.on 'end', ->
defer.resolve hasFiles
defer.promise



@@ -4,7 +4,7 @@ module.exports = (gulp, config) ->
path = require 'path'
log = require "#{config.req.helpers}/log"
promiseHelp = require "#{config.req.helpers}/promise"
dirHelper = require("#{config.req.helpers}/dir") config
dirHelper = require("#{config.req.helpers}/dir") config, gulp

# Global Objects
# ==============
@@ -6,6 +6,7 @@ module.exports = (gulp, config, watchFile={}) ->
minifyHtml = require 'gulp-minify-html'
templateCache = require 'gulp-angular-templatecache'
ngFormify = require "#{config.req.plugins}/gulp-ng-formify"
dirHelper = require("#{config.req.helpers}/dir") config, gulp
runNgFormify = config.angular.ngFormify
forWatchFile = !!watchFile.path

@@ -65,12 +66,16 @@ module.exports = (gulp, config, watchFile={}) ->
defer.promise

run = ->
defer = q.defer()
isProd = config.env.is.prod
file = if isProd then 'min' else 'main'
file = config.fileName.views[file]
dest = config.dist.rb.client.scripts.dir
src = [].concat glob.views.rb, glob.views.app
runTask src, dest, file, isProd
dirHelper.hasFiles(src).done (hasFiles) ->
return defer.resolve() unless hasFiles
runTask(src, dest, file, isProd).done -> defer.resolve()
defer.promise

runSingle = -> # todo: optimize for one file
run()

0 comments on commit e588220

Please sign in to comment.
You can’t perform that action at this time.