Comparing version 0.6.1 to 0.6.2
@@ -587,22 +587,43 @@ "use strict"; | ||
var gotAST = is.object(src); | ||
if (gotAST && !options.ast) { | ||
return { | ||
errors: ["Can't produce string output when input is an AST. Did you forget to set options.ast = true?"], | ||
var parsed; | ||
if (is.object(src)) { | ||
if (!options.ast) { | ||
return { | ||
errors: [ | ||
"Can't produce string output when input is an AST. " + | ||
"Did you forget to set options.ast = true?" | ||
], | ||
}; | ||
} | ||
} | ||
var parsed; | ||
try { | ||
parsed = options.parse(src, { | ||
loc: true, | ||
range: true, | ||
}); | ||
} catch (e) { | ||
// Received an AST object as src, so no need to parse it. | ||
parsed = src; | ||
} else if (is.string(src)) { | ||
try { | ||
parsed = options.parse(src, { | ||
loc: true, | ||
range: true, | ||
}); | ||
} catch (e) { | ||
return { | ||
errors: [ | ||
fmt("line {0} column {1}: Error during input file parsing\n{2}\n{3}", | ||
e.lineNumber, | ||
e.column, | ||
src.split("\n")[e.lineNumber - 1], | ||
fmt.repeat(" ", e.column - 1) + "^") | ||
], | ||
}; | ||
} | ||
} else { | ||
return { | ||
errors: [fmt("line {0} column {1}: Error during input file parsing\n{2}\n{3}", e.lineNumber, e.column, src.split("\n")[e.lineNumber - 1], fmt.repeat(" ", e.column - 1) + "^")], | ||
errors: ["Input was neither an AST object nor a string."], | ||
}; | ||
} | ||
var ast = (gotAST ? src : parsed); | ||
var ast = parsed; | ||
// TODO detect unused variables (never read) | ||
@@ -609,0 +630,0 @@ error.reset(); |
@@ -0,1 +1,4 @@ | ||
## v0.6.2 2013-12-09 | ||
* Fix regenerator breakage due to input handling (pr #22) | ||
## v0.6.1 2013-12-09 | ||
@@ -2,0 +5,0 @@ * Graceful error handling on malformed source input (issue #18) |
@@ -587,22 +587,43 @@ "use strict"; | ||
const gotAST = is.object(src); | ||
if (gotAST && !options.ast) { | ||
return { | ||
errors: ["Can't produce string output when input is an AST. Did you forget to set options.ast = true?"], | ||
let parsed; | ||
if (is.object(src)) { | ||
if (!options.ast) { | ||
return { | ||
errors: [ | ||
"Can't produce string output when input is an AST. " + | ||
"Did you forget to set options.ast = true?" | ||
], | ||
}; | ||
} | ||
} | ||
let parsed; | ||
try { | ||
parsed = options.parse(src, { | ||
loc: true, | ||
range: true, | ||
}); | ||
} catch (e) { | ||
// Received an AST object as src, so no need to parse it. | ||
parsed = src; | ||
} else if (is.string(src)) { | ||
try { | ||
parsed = options.parse(src, { | ||
loc: true, | ||
range: true, | ||
}); | ||
} catch (e) { | ||
return { | ||
errors: [ | ||
fmt("line {0} column {1}: Error during input file parsing\n{2}\n{3}", | ||
e.lineNumber, | ||
e.column, | ||
src.split("\n")[e.lineNumber - 1], | ||
fmt.repeat(" ", e.column - 1) + "^") | ||
], | ||
}; | ||
} | ||
} else { | ||
return { | ||
errors: [fmt("line {0} column {1}: Error during input file parsing\n{2}\n{3}", e.lineNumber, e.column, src.split("\n")[e.lineNumber - 1], fmt.repeat(" ", e.column - 1) + "^")], | ||
errors: ["Input was neither an AST object nor a string."], | ||
}; | ||
} | ||
const ast = (gotAST ? src : parsed); | ||
const ast = parsed; | ||
// TODO detect unused variables (never read) | ||
@@ -609,0 +630,0 @@ error.reset(); |
{ | ||
"name": "defs", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Static scope analysis and transpilation of ES6 block scoped const and let variables, to ES3.", | ||
@@ -5,0 +5,0 @@ "main": "build/es5/defs-main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120929
3143