Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed handling of errors in bliss-compile

  • Loading branch information...
commit 48c78983fbdf2232bc81bf782ad08883ddf6ca5a 1 parent d8b4cdb
Chris Stivers authored
47 bin/bliss-compile
View
@@ -9,28 +9,41 @@ const args = _.map(process.argv,_.identity);
const nodeExec = args.shift();
const nodeScript = args.shift();
-var bliss = template = ast = code = undefined, compileStart = compileStop = 0;
+var bliss = template = source = ast = code = undefined, compileStart = compileStop = 0;
bliss = new Bliss();
-compileStart = Date.now();
-template = bliss.compileFile(args.shift(),{
- context: {
- _: _
- }
-});
-compileStop = Date.now();
+try {
+ compileStart = Date.now();
+ template = bliss.compileFile(args.shift(),{
+ context: {
+ _: _
+ }
+ });
+ compileStop = Date.now();
+ source = template.toString();
+}
+catch (error) {
+ source = error.templateSource;
+ console.log('[ERROR]',error.toString());
+}
-formattedSource = uglify.uglify.gen_code(uglify.parser.parse(template.toString()),{
- beautify: true,
- indent_start: 0,
- indent_level: 2,
- space_colon: true
-});
+try {
+ formattedSource = uglify.uglify.gen_code(uglify.parser.parse(source),{
+ beautify: true,
+ indent_start: 0,
+ indent_level: 2,
+ space_colon: true
+ });
-console.log(formattedSource);
-console.log('/*')
+ console.log(formattedSource);
+}
+catch (error) {
+ console.log(source);
+}
+
+console.log('/*');
console.log(' * generated by:','Bliss','(https://github.com/cstivers78/bliss)');
console.log(' * generated on:',new Date());
console.log(' * compile time:',compileStop-compileStart,'ms');
-console.log(' */')
+console.log(' */');
3  lib/bliss.js
View
@@ -56,9 +56,6 @@ Bliss = (function() {
writer.write(tokenizer.tokenize(source));
tmplParams = writer.parameters;
tmplSource = writer.source(context);
- console.log("~~~~~~~~~~");
- console.log(tmplSource);
- console.log("~~~~~~~~~~");
try {
func = Function.apply(null, __slice.call(tmplParams).concat([tmplSource]));
tmpl = func.bind(context);
3  lib/browser.js
View
@@ -1072,9 +1072,6 @@
writer.write(tokenizer.tokenize(source));
tmplParams = writer.parameters;
tmplSource = writer.source(context);
- console.log("~~~~~~~~~~");
- console.log(tmplSource);
- console.log("~~~~~~~~~~");
try {
func = Function.apply(null, __slice.call(tmplParams).concat([tmplSource]));
tmpl = func.bind(context);
4 src/bliss.coffee
View
@@ -42,10 +42,6 @@ class Bliss
tmplParams = writer.parameters
tmplSource = writer.source(context)
- console.log "~~~~~~~~~~"
- console.log tmplSource
- console.log "~~~~~~~~~~"
-
try
func = Function tmplParams..., tmplSource
tmpl = func.bind(context)
Please sign in to comment.
Something went wrong with that request. Please try again.