Permalink
Browse files

add callback to precompile export, make sure console.log only fires w…

…hen verbose
  • Loading branch information...
1 parent 4de1363 commit 83a783e8e80845818a12e797b14667659cc9e051 Jeff Escalante committed Feb 14, 2013
View
@@ -1,5 +1,7 @@
+// Generated by CoffeeScript 1.4.0
#!/usr/bin/env node
;
+
var colors, cwd, fs, jsondir, jsonfile, match, precompile, settings;
jsonfile = process.argv[2] || 'tmpl-precompile.json';
@@ -28,7 +30,7 @@ if (settings !== {}) {
}
if (jsonfile.indexOf('/' > 0)) {
match = jsonfile.split(/\//);
- jsondir = match.slice(0, (match.length - 1)).join('/');
+ jsondir = match.slice(0, match.length - 1).join('/');
cwd += '/' + jsondir;
}
console.log('\n\n' + 'tmpl-precompile'.bold.underline + '\n');
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -101,7 +101,7 @@ class Precompiler
if output?
fs.writeFileSync @settings.output, buf
- console.log ('Saving ' + (if uglify isnt false then 'and Uglifying ' else '' )).bold + ':' + output
+ console.log ('Saving ' + (if uglify isnt false then 'and Uglifying ' else '' )).bold + ':' + output if @settings.verbose
if @callback? then @callback(null, buf)
@@ -174,9 +174,10 @@ Params:
"verbose": Boolean(default:false), if should output compile info on console
"relative": Boolean(default:true), if paths to each template is relative to settings file
dir(string): Main execution directory
+ cb(function): callback to run when finished
###
-module.exports.precompile = (settings,dir) ->
+module.exports.precompile = (settings,dir,cb) ->
extend(globalSettings, settings)
globalSettings.dir = dir
@@ -185,7 +186,10 @@ module.exports.precompile = (settings,dir) ->
precompiler = new Precompiler(groupSetting, callback)
precompiler.compile()
, (err, res) ->
- if err? then console.log err
- else console.log "\n\n\n...Done.\n\n"
+ if err?
+ console.log err
+ else
+ if cb? then cb()
+ console.log "\n\n\n...Done.\n\n" if @settings.verbose
module.exports.Precompiler = Precompiler

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 83a783e

Please sign in to comment.