Support back to node v4

master
James Long 2017-01-10 12:18:22 -05:00
parent 9a781cbcff
commit 4abb8ce544
6 changed files with 16 additions and 3 deletions

View File

@ -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");

View File

@ -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) {

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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");