chore: use template on core package

This commit is contained in:
Pedro Nauck
2018-04-24 10:21:01 -03:00
parent 8ccf99c764
commit 8d10aa79ed
5 changed files with 9 additions and 13 deletions

View File

@@ -10,7 +10,7 @@ import { propOf } from './utils/helpers'
import { format } from './utils/format'
import { Entry } from './Entry'
import { ConfigArgs, AppType } from './Server'
import { ConfigArgs } from './Server'
const mkd = (dir: string): void => {
try {
@@ -27,8 +27,12 @@ const touch = (file: string, raw: string) => {
fs.writeFileSync(file, content, 'utf-8')
}
const compiled = (type: AppType) => (file: string) =>
compile(fs.readFileSync(path.join(paths.templatesOf(type), file), 'utf-8'))
const compiled = (file: string) =>
compile(fs.readFileSync(path.join(paths.templates, file), 'utf-8'))
const app = compiled('app.tpl.js')
const js = compiled('index.tpl.js')
const html = compiled('index.tpl.html')
export class Entries {
public files: string[]
@@ -80,12 +84,7 @@ export class Entries {
}
public write(): void {
const { plugins, title, description, theme, type } = this.config
const template = compiled(type)
const app = template('app.tpl.js')
const js = template('index.tpl.js')
const html = template('index.tpl.html')
const { plugins, title, description, theme } = this.config
const wrappers = propOf(plugins, 'wrapper')
const afterRenders = propOf(plugins, 'afterRender')

View File

@@ -3,8 +3,6 @@ import * as path from 'path'
import * as url from 'url'
import resolve from 'resolve'
import { AppType } from '../Server'
const ENV_PUBLIC_URL = process.env.PUBLIC_URL
const ensureSlash = (filepath: any, needsSlash: boolean) => {
@@ -45,8 +43,7 @@ export interface Paths {
indexHtml: string
}
export const templatesOf = (type: AppType) =>
path.join(resolve.sync(`docz-${type}`), '../templates')
export const templates = path.join(resolve.sync('docz'), '../templates')
export const docz = resolveApp('.docz')
export const packageJson = resolveApp('package.json')