diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2022-02-27 12:55:13 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2022-02-27 12:55:13 -0400 |
commit | 33c607bbdc8211cd32232bf50cdcf7eafbaf48a7 (patch) | |
tree | 9549c51495d6aa7cff599b771ea773cc6bd90275 /src | |
parent | cd3a59d5024984a2d3be5164f6b2ce9ee05e9f62 (diff) |
warn specifically about referenced aliases
Diffstat (limited to 'src')
-rwxr-xr-x | src/upd8.js | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/upd8.js b/src/upd8.js index e903d6af..eb2da684 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -2879,7 +2879,14 @@ async function main() { if (!thing[property]) continue; if (findFnKey === '_contrib') { thing[property] = filter(thing[property], - decorateErrorWithIndex(({ who }) => boundFind.artist(who)), + decorateErrorWithIndex(({ who }) => { + const alias = find.artist(who, wikiData.artistAliasData, {mode: 'quiet'}); + if (alias) { + const original = find.artist(alias.aliasedArtistRef, wikiData.artistData, {mode: 'quiet'}); + throw new Error(`Reference ${color.red(who)} is to an alias, should be ${color.green(original.name)}`); + } + return boundFind.artist(who); + }), {message: `Reference errors in contributions ${color.green(property)}`}); continue; } @@ -2928,6 +2935,18 @@ async function main() { // appropriate. linkDataArrays(); + WD.artistAliasData = wikiData.artistData.flatMap(artist => { + const origRef = Thing.getReference(artist); + return (artist.aliasNames?.map(name => { + const alias = new Artist(); + alias.name = name; + alias.isAlias = true; + alias.aliasedArtistRef = origRef; + alias.artistData = WD.artistData; + return alias; + }) ?? []); + }); + // Filter out any reference errors throughout the data, warning about them // too. filterAndShowReferenceErrors(); @@ -2984,18 +3003,6 @@ async function main() { WD.justEverythingSortedByArtDateMan = sortByArtDate(WD.justEverythingMan.slice()); // console.log(JSON.stringify(justEverythingSortedByArtDateMan.map(toAnythingMan), null, 2)); - WD.artistAliasData = wikiData.artistData.flatMap(artist => { - const origRef = Thing.getReference(artist); - return (artist.aliasNames?.map(name => { - const alias = new Artist(); - alias.name = name; - alias.isAlias = true; - alias.aliasedArtistRef = origRef; - alias.artistData = WD.artistData; - return alias; - }) ?? []); - }); - { const directories = []; for (const { directory, name } of WD.albumData) { |