Skip to content

Commit

Permalink
handle "templates directory doesn't exist" error
Browse files Browse the repository at this point in the history
  • Loading branch information
gurza committed Sep 23, 2023
1 parent b593700 commit de2b164
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/metadata/compileViews.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { PathLike } from 'fs'
import fs from 'fs/promises'
import { compileTemplate } from './compileTemplates'
import { getTemplate, getTemplates, resetTemplates } from './getTemplates'
import {
Template,
Templates,
getTemplate,
getTemplates,
resetTemplates
} from './getTemplates'

export async function* compileViews(
viewsPath: PathLike,
templatesPath?: PathLike
) {
const templates = templatesPath
? await getTemplates(templatesPath)
: new Map()
let templates: Templates = new Map<string, Template>()
if (templatesPath)
try {
templates = await getTemplates(templatesPath)
} catch (err) {
if (err.code !== 'ENOENT') throw err
}
const unusedTemplates = []
const dir = await fs.opendir(viewsPath)
for await (const dirent of dir) {
Expand Down

0 comments on commit de2b164

Please sign in to comment.