Skip to content

Commit

Permalink
feat(#5): to json
Browse files Browse the repository at this point in the history
  • Loading branch information
h1alexbel committed May 22, 2024
1 parent 71d43c8 commit a4ead83
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/to-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,19 @@ fs = require('fs');

/**
* Flush results to JSON file.
* @param {String} filename JSON file name
* @param {String} file JSON file name
* @param {String} results Results to flush
*/
function toJson(filename, results) {
fs.writeFile(`${filename}.json`, JSON.stringify(results, null, 2));
console.log(`Results saved into ${filename}.json`);
function toJson(file, results) {
fs.writeFile(
`${file}.json`,
JSON.stringify(results, null, 2), function(err) {
if (err) {
throw err;
}
console.log(`${file}.json file saved`);
}
);
}

module.exports = toJson;

0 comments on commit a4ead83

Please sign in to comment.