diff options
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/things/art-tag.js | 1 | ||||
-rw-r--r-- | src/data/things/track.js | 6 | ||||
-rw-r--r-- | src/data/yaml.js | 54 |
3 files changed, 27 insertions, 34 deletions
diff --git a/src/data/things/art-tag.js b/src/data/things/art-tag.js index 0f888a20..9a8a75c5 100644 --- a/src/data/things/art-tag.js +++ b/src/data/things/art-tag.js @@ -25,7 +25,6 @@ export class ArtTag extends Thing { // Expose only - // Previously known as: (tag).things taggedInThings: { flags: {expose: true}, diff --git a/src/data/things/track.js b/src/data/things/track.js index c59c9303..6b1e958b 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -91,7 +91,6 @@ export class Track extends Thing { }, }, - // Previously known as: (track).aka originalReleaseTrackByRef: Thing.common.singleReference(Track), dataSourceAlbumByRef: Thing.common.singleReference(Album), @@ -241,7 +240,6 @@ export class Track extends Thing { }, }, - // Previously known as: (track).artists artistContribs: Thing.common.dynamicInheritContribs( 'artistContribsByRef', 'artistContribsByRef', @@ -249,10 +247,8 @@ export class Track extends Thing { Track.findAlbum ), - // Previously known as: (track).contributors contributorContribs: Thing.common.dynamicContribs('contributorContribsByRef'), - // Previously known as: (track).coverArtists coverArtistContribs: Thing.common.dynamicInheritContribs( 'coverArtistContribsByRef', 'trackCoverArtistContribsByRef', @@ -260,7 +256,6 @@ export class Track extends Thing { Track.findAlbum ), - // Previously known as: (track).references referencedTracks: Thing.common.dynamicThingsFromReferenceList( 'referencedTracksByRef', 'trackData', @@ -312,7 +307,6 @@ export class Track extends Thing { }, }, - // Previously known as: (track).flashes featuredInFlashes: Thing.common.reverseReferenceList( 'flashData', 'featuredTracks' diff --git a/src/data/yaml.js b/src/data/yaml.js index befd362a..f269d447 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -963,7 +963,7 @@ export async function loadAndProcessDataDocuments({dataPath}) { }); } else { const {result, aggregate} = mapAggregate( - yamlResult, + yamlResult.filter(Boolean), decorateErrorWithIndex(dataStep.processDocument), {message: `Errors processing documents`}); processResults = result; @@ -989,7 +989,7 @@ export async function loadAndProcessDataDocuments({dataPath}) { typeof dataStep.files === 'function' ? await callAsync(dataStep.files, dataPath) : dataStep.files - ) + ); if (!files) { return; @@ -1000,8 +1000,7 @@ export async function loadAndProcessDataDocuments({dataPath}) { const readResults = await mapAsync( files, (file) => readFile(file, 'utf-8').then((contents) => ({file, contents})), - {message: `Errors reading data files`} - ); + {message: `Errors reading data files`}); const yamlResults = map( readResults, @@ -1009,8 +1008,7 @@ export async function loadAndProcessDataDocuments({dataPath}) { file, documents: yaml.loadAll(contents), })), - {message: `Errors parsing data files as valid YAML`} - ); + {message: `Errors parsing data files as valid YAML`}); let processResults; @@ -1021,12 +1019,17 @@ export async function loadAndProcessDataDocuments({dataPath}) { yamlResults.forEach(({file, documents}) => { const [headerDocument, ...entryDocuments] = documents; + if (!headerDocument) { + call(decorateErrorWithFile(() => { + throw new Error(`Missing header document (empty file or erroneously starting with "---"?)`); + }), {file}); + return; + } + const header = call( decorateErrorWithFile(({document}) => - dataStep.processHeaderDocument(document) - ), - {file, document: headerDocument} - ); + dataStep.processHeaderDocument(document)), + {file, document: headerDocument}); // Don't continue processing files whose header // document is invalid - the entire file is excempt @@ -1036,14 +1039,13 @@ export async function loadAndProcessDataDocuments({dataPath}) { } const entries = map( - entryDocuments.map((document) => ({file, document})), + entryDocuments + .filter(Boolean) + .map((document) => ({file, document})), decorateErrorWithFile( decorateErrorWithIndex(({document}) => - dataStep.processEntryDocument(document) - ) - ), - {message: `Errors processing entry documents`} - ); + dataStep.processEntryDocument(document))), + {message: `Errors processing entry documents`}); // Entries may be incomplete (i.e. any errored // documents won't have a processed output @@ -1061,22 +1063,20 @@ export async function loadAndProcessDataDocuments({dataPath}) { yamlResults.forEach(({file, documents}) => { if (documents.length > 1) { - call( - decorateErrorWithFile(() => { - throw new Error( - `Only expected one document to be present per file` - ); - }) - ); + call(decorateErrorWithFile(() => { + throw new Error(`Only expected one document to be present per file`); + }), {file}); return; + } else if (empty(documents) || !documents[0]) { + call(decorateErrorWithFile(() => { + throw new Error(`Expected a document, this file is empty`); + }), {file}); } const result = call( decorateErrorWithFile(({document}) => - dataStep.processDocument(document) - ), - {file, document: documents[0]} - ); + dataStep.processDocument(document)), + {file, document: documents[0]}); if (!result) { return; |