Skip to content

Commit

Permalink
feat: use platform placeholder for wp config
Browse files Browse the repository at this point in the history
  • Loading branch information
yarastqt committed Jul 6, 2020
1 parent dec858a commit ab3545a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { dedupeProps } from './dedupe-props'
import { loadSources } from './load-sources'
import { Config } from './config'
import { isColor } from './utils'
import { enhanceWhitepaperConfig } from './enhance-whitepaper-config'

const store = new Map()

Expand Down Expand Up @@ -82,7 +83,7 @@ export async function build(config: Config): Promise<void> {

// TODO: Load mappers in themes?
store.set('mapper', await loadMappers(theme.mappers))
store.set('whitepaper', theme.whitepaper)
store.set('whitepaper', enhanceWhitepaperConfig(theme.whitepaper, platform))

const StyleDictionary = StyleDictionaryApi.extend(
createStyleDictionaryConfig({
Expand Down
12 changes: 12 additions & 0 deletions src/core/enhance-whitepaper-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type WhitepaperConfig = Record<string, string>

export function enhanceWhitepaperConfig(
config: WhitepaperConfig,
platform: string,
): WhitepaperConfig {
const result: WhitepaperConfig = {}
for (const key in config) {
result[key] = config[key].replace(/\[platform\]/, platform)
}
return result
}

0 comments on commit ab3545a

Please sign in to comment.