38 lines
829 B
TypeScript
38 lines
829 B
TypeScript
import { name, version, license, url, author } from '../../package.json'
|
|
import appRoot from 'app-root-path'
|
|
import colors from '../palette'
|
|
import Color from '../helpers/color'
|
|
import { renderToFile } from '../helpers/file'
|
|
|
|
const templateFile = appRoot + '/src/build/templates/yaml.hbs'
|
|
const outputFile = appRoot + '/dist/palette.yml'
|
|
|
|
export default async function(isVerbose = false): Promise<string> {
|
|
try {
|
|
await renderToFile(templateFile, outputFile, getData(), isVerbose)
|
|
|
|
return outputFile
|
|
} catch (error) {
|
|
throw error
|
|
}
|
|
}
|
|
|
|
function getData(): any {
|
|
return {
|
|
name,
|
|
version,
|
|
license,
|
|
url,
|
|
author,
|
|
colors: colors.map(getDataColors)
|
|
}
|
|
}
|
|
|
|
function getDataColors(color: Color): any {
|
|
const { nameSnakeCase } = color
|
|
|
|
return {
|
|
nameSnakeCase,
|
|
hex: color.toHex()
|
|
}
|
|
}
|