From 1e64dcf379fbc45eab7da9bdd16cd03dc93bf50b Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 26 Jun 2022 12:12:24 -0300 Subject: experimental cache & checks code This is actually from a while ago, it's just been sitting around in my working directory for ages because I am bad at git. --- src/wiki-checks.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/wiki-checks.js (limited to 'src/wiki-checks.js') diff --git a/src/wiki-checks.js b/src/wiki-checks.js new file mode 100644 index 0000000..af8a270 --- /dev/null +++ b/src/wiki-checks.js @@ -0,0 +1,56 @@ +import { quickLoadAllFromYAML } from './data/yaml.js'; +import { logError, parseOptions } from './util/cli.js'; +import { isMain } from './util/node-utils.js'; +import { showAggregate } from './util/sugar.js'; + +export default async function performAllChecks({ + dataPath, + mediaPath, +}) { + const wikiData = await quickLoadAllFromYAML(dataPath); + + console.log(wikiData); +} + +if (isMain(import.meta.url)) { + (async function() { + const miscOptions = await parseOptions(process.argv.slice(2), { + 'data-path': { + type: 'value' + }, + + 'media-path': { + type: 'value' + }, + + 'show-traces': { + type: 'flag' + }, + }); + + const dataPath = miscOptions['data-path'] || process.env.HSMUSIC_DATA; + const mediaPath = miscOptions['media-path'] || process.env.HSMUSIC_MEDIA; + + if (!dataPath) { + logError`Expected --data-path option or HSMUSIC_DATA to be set`; + return; + } + + const niceShowAggregate = (error, ...opts) => { + showAggregate(error, { + showTraces: showAggregateTraces, + pathToFile: f => path.relative(__dirname, f), + ...opts + }); + }; + + await performAllChecks({ + dataPath, + mediaPath, + + showAggregate: niceShowAggregate, + }); + })().catch(err => { + console.error(err); + }); +} -- cgit 1.3.0-6-gf8a5