Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

…hen verbose
  • Loading branch information...
commit 83a783e8e80845818a12e797b14667659cc9e051 1 parent 4de1363
@jenius jenius authored
View
4 bin/tmpl-precompile
@@ -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
4 bin/tmpl-precompile.js
@@ -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
2  index.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
(function() {
module.exports = require('./lib/tmpl-precompile');
View
2  lib/helpers.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
/*
extend(main, sub)
View
2  lib/namespace.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
(function() {
var Namespacer, async;
View
2  lib/optimize.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
(function() {
var extractFunction, jsp, optimizeOutput;
View
16 lib/tmpl-precompile.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
(function() {
var Namespacer, Precompiler, async, colors, extend, extractFunction, fs, globalSettings, jade, jsp, optimizeOutput, path, pro, util, version, _ref;
@@ -121,7 +121,9 @@
}
if (output != null) {
fs.writeFileSync(this.settings.output, buf);
- console.log(('Saving ' + (uglify !== false ? 'and Uglifying ' : '')).bold + ':' + output);
+ if (this.settings.verbose) {
+ console.log(('Saving ' + (uglify !== false ? 'and Uglifying ' : '')).bold + ':' + output);
+ }
}
if (this.callback != null) {
return this.callback(null, buf);
@@ -198,10 +200,11 @@
"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 = function(settings, dir) {
+ module.exports.precompile = function(settings, dir, cb) {
extend(globalSettings, settings);
globalSettings.dir = dir;
return async.forEach(settings.groups, function(groupSetting, callback) {
@@ -212,7 +215,12 @@
if (err != null) {
return console.log(err);
} else {
- return console.log("\n\n\n...Done.\n\n");
+ if (cb != null) {
+ cb();
+ }
+ if (this.settings.verbose) {
+ return console.log("\n\n\n...Done.\n\n");
+ }
}
});
};
View
12 src/lib/tmpl-precompile.coffee
@@ -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
View
2  test/mock/precompiler.mock.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
(function() {
var async, fs, mockData, path, setupStubs, teardownStubs, tmpl1, tmpl2;
View
2  test/namespace.test.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
(function() {
var assert, longGroupNamespace, longTemplateAndGroupNames, longTemplateNames, namespace, namespaceTest, noNamespaceError, noTemplatesError, singleNamespace, vows;
View
2  test/precompiler.test.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
(function() {
var Precompiler, assert, compileDebug, defaultSettings, fs, inlineRuntime, jsp, mockData, noHelpers, noUglify, outputFile, precompilerTest, pro, setup, setupPrecompiler, setupStubs, teardown, teardownStubs, vows, _ref;
Please sign in to comment.
Something went wrong with that request. Please try again.