-
Notifications
You must be signed in to change notification settings - Fork 0
/
trello-notes-to-md.js
41 lines (35 loc) · 1.06 KB
/
trello-notes-to-md.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import csv from "csvtojson"
import { writeFile } from "fs/promises"
const inputFileName = "notes.csv"
try {
const parsed = await csv().fromFile(`./resources/${inputFileName}`)
const grouped = groupByListName(parsed)
const entries = Object.entries(grouped)
const files = await writeFilesForEntries(entries)
} catch (err) {
console.error(err);
}
function groupByListName(ungrouped) {
const groups = {}
ungrouped.forEach(item => {
const check = groups[item.listName]
if (check) {
check.push(item.cardName)
} else {
groups[item.listName] = [item.cardName]
}
})
return groups
}
async function writeFilesForEntries(entries) {
return entries.map(async ([sessionName, sessionNotes]) => {
let content = ""
console.log(sessionName, sessionNotes);
content += `# ${sessionName} Notes:\n`
sessionNotes.forEach(note => {
content += `- ${note}\n`
})
await writeFile(`output/${sessionName}.md`, content)
return content
})
}