fix up comments option
This commit is contained in:
@@ -29,11 +29,11 @@ File.normaliseOptions = function (opts) {
|
||||
blacklist: [],
|
||||
whitelist: [],
|
||||
sourceMap: false,
|
||||
comments: true,
|
||||
filename: "unknown",
|
||||
modules: "common",
|
||||
runtime: false,
|
||||
code: true,
|
||||
comments: true
|
||||
code: true
|
||||
});
|
||||
|
||||
// normalise windows path separators to unix
|
||||
|
||||
@@ -17,11 +17,10 @@ var _ = require("lodash");
|
||||
function CodeGenerator(ast, opts, code) {
|
||||
opts = opts || {};
|
||||
|
||||
this.keepComments = opts.comments !== false;
|
||||
this.comments = ast.comments || [];
|
||||
this.tokens = ast.tokens || [];
|
||||
this.format = CodeGenerator.normaliseOptions(opts);
|
||||
this.ast = ast;
|
||||
this.comments = ast.comments || [];
|
||||
this.tokens = ast.tokens || [];
|
||||
this.format = CodeGenerator.normaliseOptions(opts);
|
||||
this.ast = ast;
|
||||
|
||||
this.whitespace = new Whitespace(this.tokens, this.comments);
|
||||
this.position = new Position;
|
||||
@@ -41,7 +40,7 @@ CodeGenerator.normaliseOptions = function (opts) {
|
||||
opts = _.merge({
|
||||
parentheses: true,
|
||||
semicolons: true,
|
||||
comments: true,
|
||||
comments: opts.comments,
|
||||
compact: false,
|
||||
indent: {
|
||||
adjustMultilineComment: true,
|
||||
@@ -142,10 +141,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
};
|
||||
|
||||
if (this[node.type]) {
|
||||
|
||||
if(this.keepComments) {
|
||||
this.printLeadingComments(node, parent);
|
||||
}
|
||||
this.printLeadingComments(node, parent);
|
||||
|
||||
newline(true);
|
||||
|
||||
@@ -166,9 +162,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
|
||||
newline(false);
|
||||
|
||||
if(this.keepComments) {
|
||||
this.printTrailingComments(node, parent);
|
||||
}
|
||||
this.printTrailingComments(node, parent);
|
||||
} else {
|
||||
throw new ReferenceError("unknown node " + node.type + " " + JSON.stringify(node));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user