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 () {
|
Buffer.prototype.getIndent = function () {
|
||||||
if (this.format.compact) {
|
if (this.format.compact || this.format.concise) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
return util.repeat(this._indent, this.format.indent.style);
|
return util.repeat(this._indent, this.format.indent.style);
|
||||||
@ -72,7 +72,7 @@ Buffer.prototype.removeLast = function (cha) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Buffer.prototype.newline = function (i, removeLast) {
|
Buffer.prototype.newline = function (i, removeLast) {
|
||||||
if (this.format.compact) {
|
if (this.format.compact || this.format.concise) {
|
||||||
this.space();
|
this.space();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -50,6 +50,7 @@ CodeGenerator.normalizeOptions = function (code, opts) {
|
|||||||
parentheses: true,
|
parentheses: true,
|
||||||
comments: opts.comments == null || opts.comments,
|
comments: opts.comments == null || opts.comments,
|
||||||
compact: false,
|
compact: false,
|
||||||
|
concise: false,
|
||||||
indent: {
|
indent: {
|
||||||
adjustMultilineComment: true,
|
adjustMultilineComment: true,
|
||||||
style: style,
|
style: style,
|
||||||
@ -139,9 +140,9 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
|||||||
node._compact = true;
|
node._compact = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldCompact = this.format.compact;
|
var oldConcise = this.format.concise;
|
||||||
if (node._compact) {
|
if (node._compact) {
|
||||||
this.format.compact = true;
|
this.format.concise = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
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));
|
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) {
|
CodeGenerator.prototype.printJoin = function (print, nodes, opts) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user