Comparing version 4.6.3 to 4.7.0
@@ -6,2 +6,4 @@ module.exports = { | ||
summaryOutput: null, | ||
// Format of the summary output that's generated ('object' or 'array'). | ||
summaryOutputFormat: 'object', | ||
// Watch mode, recompile on file changes. | ||
@@ -8,0 +10,0 @@ watch: false, |
14
index.js
@@ -87,2 +87,3 @@ 'use strict' | ||
let finishCount = 0 | ||
const summaryArray = [] | ||
result.forEach(function (file, i) { | ||
@@ -104,2 +105,3 @@ processingFunc(file, options, function (newFile, content) { | ||
summaryObj.fileMap[filename] = val | ||
summaryArray.push(val) | ||
@@ -119,5 +121,11 @@ if (finishCount === result.length) { | ||
if (options.summaryOutput) { | ||
writeFileContent(options.summaryOutput, JSON.stringify(summaryObj, null, 2), function (e, d) { | ||
resolve(summaryObj) | ||
}) | ||
if (options.summaryOutputFormat === 'array') { | ||
writeFileContent(options.summaryOutput, JSON.stringify(summaryArray, null, 2), function (e, d) { | ||
resolve(summaryArray) | ||
}) | ||
} else { | ||
writeFileContent(options.summaryOutput, JSON.stringify(summaryObj, null, 2), function (e, d) { | ||
resolve(summaryObj) | ||
}) | ||
} | ||
} else { | ||
@@ -124,0 +132,0 @@ resolve(summaryObj) |
{ | ||
"name": "processmd", | ||
"version": "4.6.3", | ||
"version": "4.7.0", | ||
"description": "Process a directory of markdown and yaml files to JSON files", | ||
@@ -14,2 +14,3 @@ "main": "index.js", | ||
"build:summary": "node cli.js \"test/data/input/**/*.{yml,md}\" --stdout --preview 40 --summaryOutput test/data/outputSummary.json --outputDir test/data/output", | ||
"build:summary:array": "node cli.js \"test/data/input/**/*.{yml,md}\" --stdout --preview 40 --summaryOutput test/data/outputSummaryArray.json --summaryOutputFormat array --outputDir test/data/output", | ||
"build:yaml": "node cli.js \"test/data/output/**/*.json\" --stdout --includeBodyProps --summaryOutput test/data/back.json --convertMode source --outputDir test/data/input", | ||
@@ -16,0 +17,0 @@ "build:all": "npm run build:json && npm run build:summary && npm run build:yaml", |
56481
24
974