Support back to node v4
parent
9a781cbcff
commit
4abb8ce544
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const minimist = require("minimist");
|
const minimist = require("minimist");
|
||||||
|
|
4
index.js
4
index.js
|
@ -1,3 +1,4 @@
|
||||||
|
"use strict";
|
||||||
const babylon = require("babylon");
|
const babylon = require("babylon");
|
||||||
const Printer = require("./src/printer").Printer;
|
const Printer = require("./src/printer").Printer;
|
||||||
const flowParser = require("flow-parser");
|
const flowParser = require("flow-parser");
|
||||||
|
@ -26,7 +27,8 @@ var babylonOptions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
format: function(text, opts={}) {
|
format: function(text, opts) {
|
||||||
|
opts = opts || {};
|
||||||
let ast;
|
let ast;
|
||||||
|
|
||||||
if(opts.useFlowParser) {
|
if(opts.useFlowParser) {
|
||||||
|
|
11
src/pp.js
11
src/pp.js
|
@ -1,3 +1,4 @@
|
||||||
|
"use strict";
|
||||||
const assert = require("assert");
|
const assert = require("assert");
|
||||||
|
|
||||||
function assertDoc(val) {
|
function assertDoc(val) {
|
||||||
|
@ -156,7 +157,10 @@ function fits(next, restCommands, width) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [ ind, mode, doc ] = cmds.pop();
|
const x = cmds.pop();
|
||||||
|
const ind = x[0];
|
||||||
|
const mode = x[1];
|
||||||
|
const doc = x[2];
|
||||||
|
|
||||||
if (typeof doc === "string") {
|
if (typeof doc === "string") {
|
||||||
width -= doc.length;
|
width -= doc.length;
|
||||||
|
@ -213,7 +217,10 @@ function print(w, doc) {
|
||||||
let out = [];
|
let out = [];
|
||||||
let shouldRemeasure = false;
|
let shouldRemeasure = false;
|
||||||
while (cmds.length !== 0) {
|
while (cmds.length !== 0) {
|
||||||
const [ ind, mode, doc ] = cmds.pop();
|
const x = cmds.pop();
|
||||||
|
const ind = x[0];
|
||||||
|
const mode = x[1];
|
||||||
|
const doc = x[2];
|
||||||
|
|
||||||
if (typeof doc === "string") {
|
if (typeof doc === "string") {
|
||||||
out.push(doc);
|
out.push(doc);
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
"use strict";
|
||||||
var assert = require("assert");
|
var assert = require("assert");
|
||||||
var sourceMap = require("source-map");
|
var sourceMap = require("source-map");
|
||||||
var printComments = require("./comments").printComments;
|
var printComments = require("./comments").printComments;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
"use strict";
|
||||||
var assert = require("assert");
|
var assert = require("assert");
|
||||||
var types = require("ast-types");
|
var types = require("ast-types");
|
||||||
var getFieldValue = types.getFieldValue;
|
var getFieldValue = types.getFieldValue;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
"use strict";
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const jscodefmt = require("../");
|
const jscodefmt = require("../");
|
||||||
const recast = require("recast");
|
const recast = require("recast");
|
||||||
|
|
Loading…
Reference in New Issue