Skip to content

Commit

Permalink
feat: support js format for config
Browse files Browse the repository at this point in the history
  • Loading branch information
yarastqt committed Apr 26, 2020
1 parent 1649bb6 commit 231a795
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
7 changes: 4 additions & 3 deletions src/cli/build.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { resolve } from 'path'
import { Command, flags } from '@oclif/command'
import createSpinner, { Ora as Spinner } from 'ora'
import chalk from 'chalk'

import { getProjectConfig } from '../core/project-config'
import { loadConfig } from '../core/config'
import { build } from '../core/build'

type Flags = { config: string }
Expand All @@ -12,14 +13,14 @@ export default class Build extends Command {
config: flags.string({
char: 'c',
description: 'Config path',
default: 'theme.config.json',
default: 'themekit.config.js',
}),
}

async run() {
let spinner: Spinner
const { flags } = this.parse<Flags, any>(Build)
const config = await getProjectConfig(process.cwd(), flags.config)
const config = await loadConfig(resolve(flags.config))
await build(
config,
(format) => {
Expand Down
2 changes: 1 addition & 1 deletion src/core/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { writeFile, ensureDir } from 'fs-extra'
import { join, resolve, parse } from 'path'
import deepmerge from 'deepmerge'

import { Config } from './project-config'
import { Config } from './config'
import { getThemeLayers } from './theme-layers'
import { flatTokens } from './flat-tokens'
import { transformTokens } from './transforms'
Expand Down
17 changes: 17 additions & 0 deletions src/core/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Platforms } from './platforms'

export type Config = {
src: string
platforms?: Platforms
formats: {
[key: string]: {
outDir: string
transforms: string[]
options?: {}
}
}
}

export async function loadConfig(path: string): Promise<Config> {
return await import(path)
}
21 changes: 0 additions & 21 deletions src/core/project-config.ts

This file was deleted.

0 comments on commit 231a795

Please sign in to comment.