From b3cd2aa41af9ee98580a00f16b8a5d0a62b8cea0 Mon Sep 17 00:00:00 2001 From: Eugene Date: Thu, 4 Jun 2020 17:35:30 +0300 Subject: [PATCH] feat: support sources as single string --- src/core-v2/themes.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core-v2/themes.ts b/src/core-v2/themes.ts index 97ecc72..c375f53 100644 --- a/src/core-v2/themes.ts +++ b/src/core-v2/themes.ts @@ -13,9 +13,10 @@ function resolveRootDir(filePath: string): string { : filePath } -export async function loadThemes(sources: string[]): Promise { +export async function loadThemes(sources: string | string[]): Promise { const result: Themes = { mappers: [], sources: [], whitepaper: {} } - for (const sourcePath of sources) { + const normalizedSources = Array.isArray(sources) ? sources : [sources] + for (const sourcePath of normalizedSources) { const { mappers = [], sources = [], whitepaper }: Themes = await readJSON(sourcePath) result.mappers.push(...mappers.map(resolveRootDir)) result.sources.push(...sources.map(resolveRootDir))