Allow single quotes with --single-quotes option
parent
b550f1d088
commit
599b4311bb
|
@ -5,21 +5,18 @@ const minimist = require("minimist");
|
|||
const jscodefmt = require("../index");
|
||||
|
||||
const argv = minimist(process.argv.slice(2), {
|
||||
boolean: ["write", "useFlowParser", "bracket-spacing"]
|
||||
boolean: ["write", "useFlowParser", "bracket-spacing", "single-quotes"]
|
||||
});
|
||||
|
||||
const filename = argv["_"][0];
|
||||
const printWidth = argv['print-width'] || 80;
|
||||
const tabWidth = argv['tab-width'] || 2;
|
||||
const useFlowParser = argv['flow-parser'];
|
||||
const bracketSpacing = argv['bracket-spacing'];
|
||||
const write = argv['write'];
|
||||
|
||||
const output = jscodefmt.format(fs.readFileSync(filename, "utf8"), {
|
||||
printWidth,
|
||||
tabWidth,
|
||||
bracketSpacing,
|
||||
useFlowParser
|
||||
printWidth: argv['print-width'],
|
||||
tabWidth: argv['tab-width'],
|
||||
bracketSpacing: argv['bracket-spacing'],
|
||||
useFlowParser: argv['flow-parser'],
|
||||
quote: argv["single-quotes"] ? "single" : "double"
|
||||
});
|
||||
|
||||
if(write) {
|
||||
|
|
|
@ -1993,10 +1993,6 @@ function nodeStr(str, options) {
|
|||
isString.assert(str);
|
||||
|
||||
switch (options.quote) {
|
||||
case "auto":
|
||||
var double = JSON.stringify(str);
|
||||
var single = swapQuotes(JSON.stringify(swapQuotes(str)));
|
||||
return (double.length > single.length ? single : double);
|
||||
case "single":
|
||||
return swapQuotes(JSON.stringify(swapQuotes(str)));
|
||||
case "double":
|
||||
|
|
Loading…
Reference in New Issue