Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ function printHelp() {
w(' inspect: node.js `util.inspect` output');
w(' -i Shortcut for `-o inspect`');
w(' -j Shortcut for `-o json`');
w(' --crlf Output Windows style CRLF for line breaks as opposed to LF');
w(' -0, -2, -4 Set indentation to the given value w/o setting MODE.');
w(' -0 => -o jsony-0');
w(' -4 => -o jsony-4');
Expand Down Expand Up @@ -291,6 +292,7 @@ function parseArgv(argv) {
jsonIndent: 2,
array: null,
delim: ' ',
crlf: false,
lookupDelim: '.',
items: false,
outputKeys: false,
Expand Down Expand Up @@ -381,6 +383,9 @@ function parseArgv(argv) {
throw new Error('unknown output mode: "' + name + '"');
}
break;
case '--crlf':
parsed.crlf = true;
break;
case '-0':
parsed.jsonIndent = 0;
break;
Expand Down Expand Up @@ -1077,6 +1082,9 @@ function printDatasets(datasets, filename, headers, opts) {
var output = stringifyDatum(dataset[0], opts, isTTY);
var sep = dataset[1];
if (output && output.length) {
if (opts.crlf) {
output = output.replace(/\n/g, "\r\n");
}
write(output);
write(sep);
} else if (dataset[2]) {
Expand Down