1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/script/create-glossary-from-spreadsheet.js
Vanessa Yuen 3df90fc9b8 Hello git history spelunker!
Are you looking for something? Here is all of the GitHub Docs history in one single commit. Enjoy! 🎉
2020-09-27 14:10:11 +02:00

37 lines
766 B
JavaScript
Executable File

#!/usr/bin/env node
// [start-readme]
//
// This script turns a Google Sheets CSV spreadsheet into a YAML file.
//
// [end-readme]
const fs = require('fs')
const path = require('path')
const yaml = require('js-yaml')
const inputFile = path.join(__dirname, '../data/glossary.yml')
const glossary = yaml.safeLoad(fs.readFileSync(inputFile, 'utf8'))
console.log(glossary)
const external = []
const internal = []
glossary.forEach(term => {
if (term.internal) {
delete term.internal
internal.push(term)
} else {
external.push(term)
}
})
fs.writeFileSync(
path.join(__dirname, '../data/glossaries/internal.yml'),
yaml.safeDump(internal)
)
fs.writeFileSync(
path.join(__dirname, '../data/glossaries/external.yml'),
yaml.safeDump(external)
)