UNPKG

pinecone-cli

Version:
51 lines (50 loc) 1.55 kB
import fs from 'node:fs'; import { init } from './commands/index.js'; import { importFresh, log, styles, toRelativePath } from './utilities.js'; export const defaultConfig = { options: { source: './themes/_pinecone-color-theme.json', output: './themes', prefix: '$', watch: false, tidy: false, includeNonItalicVariants: false, }, variants: { caffe: { name: 'Caffè', type: 'dark', }, latte: { name: 'Caffè Latte', type: 'light', }, }, colors: { transparent: '#0000', background: { caffe: '#36261b', latte: '#faf8f6', }, foreground: { caffe: '#d5bbaa', latte: '#c29d84', }, }, }; export const resolveConfig = async (flags) => { const configPath = toRelativePath('pinecone.config.js'); const userConfig = await importFresh(configPath); const options = Object.assign(defaultConfig.options, userConfig?.options, flags); if (typeof userConfig === 'undefined') { if (fs.existsSync(configPath)) { log.error(` Unable to read ${styles.string('pinecone.config.js')}. This is likely due to invalid syntax. `); throw new TypeError('Unable to read user config.'); } await init(flags?.source ?? defaultConfig.options.source); } return { ...defaultConfig, ...userConfig, options: { ...options } }; }; export const defineConfig = (config) => config;