Using YAML rather than TSV for index files. Improves both readability and reindexability.

This commit is contained in:
2024-09-11 05:16:56 +02:00
parent f41b788183
commit 029351f228
9 changed files with 73 additions and 91 deletions

View File

@@ -3,7 +3,7 @@
const config = require('config');
const Promise = require('bluebird');
const fs = require('fs-extra');
const csvParse = Promise.promisify(require('csv').parse);
const yaml = require('js-yaml');
const getArchivePostIds = require('../archives/getArchivePostIds.js');
const curateUser = require('../curate/user.js');
@@ -51,7 +51,7 @@ async function getIndexedPosts(user) {
try {
const indexFile = await fs.readFile(indexFilePath, 'utf8');
return await csvParse(indexFile, { delimiter: '\t', columns: true, cast: true });
return yaml.safeLoad(indexFile);
} catch (error) {
console.log('\x1b[33m%s\x1b[0m', `Could not load index file for '${user.name}' at '${indexFilePath}': ${error}`);