refactor: createApp

This commit is contained in:
pooya parsa 2020-08-19 15:11:52 +02:00
parent e6a5037aa2
commit 5b2f0fa191
2 changed files with 5 additions and 5 deletions

View File

@ -14,7 +14,7 @@ export interface NuxtApp {
} }
// Scan project structure // Scan project structure
export async function resolveApp (builder: Builder, options: Partial<NuxtApp> = {}): Promise<NuxtApp> { export async function createApp (builder: Builder, options: Partial<NuxtApp> = {}): Promise<NuxtApp> {
const { nuxt } = builder const { nuxt } = builder
// Create base app object // Create base app object

View File

@ -10,7 +10,7 @@ import {
NuxtTemplate NuxtTemplate
} from './template' } from './template'
import { createWatcher } from './watch' import { createWatcher } from './watch'
import { resolveApp, NuxtApp } from './app' import { createApp, NuxtApp } from './app'
import Ignore from './ignore' import Ignore from './ignore'
export class Builder { export class Builder {
@ -56,8 +56,8 @@ function watch (builder: Builder) {
nuxtAppWatcher.watchAll(debounce(() => compileTemplates(builder.templates, nuxt.options.buildDir), 100)) nuxtAppWatcher.watchAll(debounce(() => compileTemplates(builder.templates, nuxt.options.buildDir), 100))
// Watch user app // Watch user app
const appPattern = `${builder.app.srcDir}/**/*.{${nuxt.options.extensions.join(',')}}` const appPattern = `${builder.app.dir}/**/*.{${nuxt.options.extensions.join(',')}}`
const appWatcher = createWatcher(appPattern, { ...options, cwd: builder.app.srcDir }, ignore) const appWatcher = createWatcher(appPattern, { ...options, cwd: builder.app.dir }, ignore)
// appWatcher.debug('srcDir') // appWatcher.debug('srcDir')
const refreshTemplates = debounce(() => generate(builder), 100) const refreshTemplates = debounce(() => generate(builder), 100)
// Watch for App.vue creation // Watch for App.vue creation
@ -70,7 +70,7 @@ export async function generate (builder: Builder) {
const { nuxt } = builder const { nuxt } = builder
await fsExtra.mkdirp(nuxt.options.buildDir) await fsExtra.mkdirp(nuxt.options.buildDir)
builder.app = await resolveApp(builder) builder.app = await createApp(builder)
const templatesDir = join(builder.nuxt.options.appDir, '_templates') const templatesDir = join(builder.nuxt.options.appDir, '_templates')
const appTemplates = await scanTemplates(templatesDir, templateData(builder)) const appTemplates = await scanTemplates(templatesDir, templateData(builder))