       contents = uglify contents if @mode is 'production' and @minify
       fingerprint = '-' + fingerprintForPkg('jst', pkg)
       filename = "#{pkg}#{fingerprint ? ''}.jst.js"
-      writeFile filename , contents
-      if @gzip then gzipPkg(contents, filename, callback) else callback()
-      total++
+      writeFile filename , contents, (err) =>
+        if @gzip then gzipPkg(contents, filename, callback) else callback()
+        total++
 
 # Instead of compiling & writing the packages to disk, nap will compile and serve the files in
 # memory per request.

      contents = uglify contents if @mode is 'production' and @minify
      fingerprint = '-' + fingerprintForPkg('js', pkg)
      filename = "#{pkg}#{fingerprint ? ''}.js"
      writeFile filename, contents
      if @gzip then gzipPkg(contents, filename, callback) else callback()
      total++

  if @assets.css?
    for pkg, files of @assets.css

      contents = sqwish.minify contents if @mode is 'production'
      fingerprint = '-' + fingerprintForPkg('css', pkg)
      filename = "#{pkg}#{fingerprint ? ''}.css"
      writeFile filename, contents, (err) =>
        if @gzip then gzipPkg(contents, filename, callback) else callback()
        total++

  if @assets.jst?
    for pkg, files of @assets.jst
