From b37e8bc8e7e8f6eb88519dbbe44b9ff81a48c2e3 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Tue, 24 May 2022 16:51:06 -0500 Subject: [PATCH] Use listEndpointPrefix to prevent kind collisions --- build-lists.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build-lists.js b/build-lists.js index e253649..3aa4c9a 100644 --- a/build-lists.js +++ b/build-lists.js @@ -145,6 +145,10 @@ class BuildLists { } ] + getListOptions ( listName ) { + return this.listsOptions.find( listOption => listOption.name === listName ) + } + shouldHaveRelatedVideos ( app ) { const appType = getAppType( app ) @@ -328,9 +332,12 @@ class BuildLists { makeKindLists () { const getters = Object.fromEntries( Object.entries( this.lists ).map( ([ listName ]) => { + + const listEndpointPrefix = this.getListOptions( listName ).endpointPrefix + return [ // Key - listName, + listEndpointPrefix, () => this.getListArrayMemoized( listName ) ] } ) ) @@ -338,12 +345,17 @@ class BuildLists { // Add getters for categories // Homebrew category overrides Homebrew app type from above for ( const categorySlug in categories ) { + // Throw if category already defined + if ( getters[categorySlug] ) throw Error(`Category ${categorySlug} already defined`) + getters[categorySlug] = () => this.getAppCategoryList( categorySlug ) } const kindLists = {} for ( const kindSlug in getters ) { + // Throw if kindSlug already defined + if ( kindLists[kindSlug] ) throw Error(`Kind ${kindSlug} already defined`) kindLists[ kindSlug ] = new KindList({ // Get list method