1
0
mirror of synced 2025-12-20 10:28:40 -05:00
Files
docs/script/create-glossary-from-spreadsheet.js
Kevin Heis b29e37318a Remove import x statements (#20594)
* Clear out most import x

* Update rimraf use

* Move up readme blocks in scripts
2021-07-29 20:28:30 +00:00

35 lines
845 B
JavaScript
Executable File

#!/usr/bin/env node
// [start-readme]
//
// This script turns a Google Sheets CSV spreadsheet into a YAML file.
//
// [end-readme]
import { fileURLToPath } from 'url'
import path from 'path'
import fs from 'fs/promises'
import yaml from 'js-yaml'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const inputFile = path.join(__dirname, '../data/glossary.yml')
const glossary = yaml.load(await fs.readFile(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)
}
})
await fs.writeFile(path.join(__dirname, '../data/glossaries/internal.yml'), yaml.dump(internal))
await fs.writeFile(path.join(__dirname, '../data/glossaries/external.yml'), yaml.dump(external))