add concise format option
This commit is contained in:
parent
23c6e7e168
commit
86fbba08d8
@ -19,7 +19,7 @@ Buffer.prototype.get = function () {
|
||||
};
|
||||
|
||||
Buffer.prototype.getIndent = function () {
|
||||
if (this.format.compact) {
|
||||
if (this.format.compact || this.format.concise) {
|
||||
return "";
|
||||
} else {
|
||||
return util.repeat(this._indent, this.format.indent.style);
|
||||
@ -72,7 +72,7 @@ Buffer.prototype.removeLast = function (cha) {
|
||||
};
|
||||
|
||||
Buffer.prototype.newline = function (i, removeLast) {
|
||||
if (this.format.compact) {
|
||||
if (this.format.compact || this.format.concise) {
|
||||
this.space();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -50,6 +50,7 @@ CodeGenerator.normalizeOptions = function (code, opts) {
|
||||
parentheses: true,
|
||||
comments: opts.comments == null || opts.comments,
|
||||
compact: false,
|
||||
concise: false,
|
||||
indent: {
|
||||
adjustMultilineComment: true,
|
||||
style: style,
|
||||
@ -139,9 +140,9 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
node._compact = true;
|
||||
}
|
||||
|
||||
var oldCompact = this.format.compact;
|
||||
var oldConcise = this.format.concise;
|
||||
if (node._compact) {
|
||||
this.format.compact = true;
|
||||
this.format.concise = true;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
@ -208,7 +209,7 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name));
|
||||
}
|
||||
|
||||
this.format.compact = oldCompact;
|
||||
this.format.concise = oldConcise;
|
||||
};
|
||||
|
||||
CodeGenerator.prototype.printJoin = function (print, nodes, opts) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user