mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-20 15:00:42 -07:00
refactor: remove mock-fs from dev dependency
This commit is contained in:
+21
-1
@@ -1,3 +1,5 @@
|
||||
import * as _ from './util/underscore'
|
||||
|
||||
export interface LiquidOptions {
|
||||
/** `root` is a directory or an array of directories to resolve layouts and includes, as well as the filename passed in when calling `.renderFile()`. If an array, the files are looked up in the order they occur in the array. Defaults to `["."]` */
|
||||
root?: string | string[]
|
||||
@@ -23,7 +25,11 @@ export interface LiquidOptions {
|
||||
greedy?: boolean
|
||||
}
|
||||
|
||||
export const defaultOptions: LiquidOptions = {
|
||||
export interface NormalizedOptions extends LiquidOptions {
|
||||
root?: string[]
|
||||
}
|
||||
|
||||
export const defaultOptions: NormalizedOptions = {
|
||||
root: ['.'],
|
||||
cache: false,
|
||||
extname: '',
|
||||
@@ -36,3 +42,17 @@ export const defaultOptions: LiquidOptions = {
|
||||
strict_filters: false,
|
||||
strict_variables: false
|
||||
}
|
||||
|
||||
export function normalize (options: LiquidOptions): NormalizedOptions {
|
||||
options = options || {}
|
||||
if (options.hasOwnProperty('root')) {
|
||||
options.root = normalizeStringArray(options.root)
|
||||
}
|
||||
return options as NormalizedOptions
|
||||
}
|
||||
|
||||
function normalizeStringArray (value: string | string[]): string[] {
|
||||
if (_.isArray(value)) return value as string[]
|
||||
if (_.isString(value)) return [value as string]
|
||||
return []
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user