damus-github-export

Damus issue data exported from github
git clone git://jb55.com/damus-github-export
Log | Files | Refs | README | LICENSE

commit 56f447ad134e5647ad97208e72a3c100a7b8963e
parent c61e43b446ef76eeb467c559d2aec638101e4feb
Author: Gavin Rehkemper <gavinr@users.noreply.github.com>
Date:   Wed, 29 Mar 2023 23:09:30 -0500

fix: export issue (#102)


Diffstat:
Mexport.js | 53++++++++++++++++++++++++++---------------------------
1 file changed, 26 insertions(+), 27 deletions(-)

diff --git a/export.js b/export.js @@ -52,35 +52,34 @@ const getFullCommentData = async (octokit, values, data, verbose = false) => { const writeFile = async (data, fileName = false) => { return new Promise((resolve, reject) => { - converter.json2csv( - data, - (err, csvString) => { - if (err) { + converter + .json2csv(data, { + emptyFieldValue: "", + }) + .then( + (csvString) => { + if (!fileName) { + const now = new Date(); + fileName = `${now.getFullYear()}-${twoPadNumber( + now.getMonth() + 1 + )}-${twoPadNumber(now.getDate())}-${twoPadNumber( + now.getHours() + )}-${twoPadNumber(now.getMinutes())}-${twoPadNumber( + now.getSeconds() + )}-issues.csv`; + } + fs.writeFile(fileName, csvString, "utf8", function (err) { + if (err) { + reject(new Error("Error writing the file.")); + } else { + resolve(fileName); + } + }); + }, + () => { reject(new Error("Invalid!")); } - - if (!fileName) { - const now = new Date(); - fileName = `${now.getFullYear()}-${twoPadNumber( - now.getMonth() + 1 - )}-${twoPadNumber(now.getDate())}-${twoPadNumber( - now.getHours() - )}-${twoPadNumber(now.getMinutes())}-${twoPadNumber( - now.getSeconds() - )}-issues.csv`; - } - fs.writeFile(fileName, csvString, "utf8", function (err) { - if (err) { - reject(new Error("Error writing the file.")); - } else { - resolve(fileName); - } - }); - }, - { - emptyFieldValue: "", - } - ); + ); }); };