diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-02-22 20:35:10 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-02-22 21:12:25 -0400 |
commit | 2d836f4c2ab3895d675b5d8a93e36922e38fbf35 (patch) | |
tree | fda5e4badbbe9a4e2f83217f2892a5df8c630fb2 /src/write/build-modes | |
parent | e0bf4a7ae3a6ec2f2278f0a62efac45466397803 (diff) |
data: SortingRule: multiple rules, one file (hopefully)
Diffstat (limited to 'src/write/build-modes')
-rw-r--r-- | src/write/build-modes/sort.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/write/build-modes/sort.js b/src/write/build-modes/sort.js index 0b759c45..df531dfa 100644 --- a/src/write/build-modes/sort.js +++ b/src/write/build-modes/sort.js @@ -2,6 +2,7 @@ export const description = `Update data files in-place to satisfy custom sorting import {logInfo} from '#cli'; import {empty} from '#sugar'; +import thingConstructors from '#things'; export const config = { fileSizes: { @@ -39,23 +40,21 @@ export async function go({wikiData, dataPath}) { return true; } + const {SortingRule} = thingConstructors; + let numUpdated = 0; let numActive = 0; - for (const sortingRule of wikiData.sortingRules) { - if (!sortingRule.active) continue; - + for await (const result of SortingRule.go({wikiData, dataPath})) { numActive++; - const niceMessage = `"${sortingRule.message}"`; - - if (sortingRule.check({wikiData})) { - logInfo`Already good: ${niceMessage}`; - } else { - logInfo`Updating to satisfy ${niceMessage}.`; - await sortingRule.apply({wikiData, dataPath}); + const niceMessage = `"${result.rule.message}"`; + if (result.changed) { numUpdated++; + logInfo`Updating to satisfy ${niceMessage}.`; + } else { + logInfo`Already good: ${niceMessage}`; } } |