mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 05:50:43 -07:00
test: cover all
This commit is contained in:
+1
-1
@@ -90,7 +90,7 @@ const _engine = {
|
||||
function normalizeStringArray (value) {
|
||||
if (_.isArray(value)) return value
|
||||
if (_.isString(value)) return [value]
|
||||
return []
|
||||
throw new TypeError('illegal root: ' + value)
|
||||
}
|
||||
|
||||
export default function Liquid (options) {
|
||||
|
||||
+5
-9
@@ -3,10 +3,13 @@ import path from 'path'
|
||||
import {anySeries} from './util/promise.js'
|
||||
import {statFileAsync, readFileAsync} from './util/fs.js'
|
||||
|
||||
function lookup (filepath, root, options) {
|
||||
export async function resolve (filepath, root, options) {
|
||||
if (!path.extname(filepath)) {
|
||||
filepath += options.extname
|
||||
}
|
||||
root = options.root.concat(root || [])
|
||||
root = _.uniq(root)
|
||||
const paths = root.map(root => path.resolve(root || location.href, filepath))
|
||||
const paths = root.map(root => path.resolve(root, filepath))
|
||||
return anySeries(paths, async path => {
|
||||
try {
|
||||
await statFileAsync(path)
|
||||
@@ -18,13 +21,6 @@ function lookup (filepath, root, options) {
|
||||
})
|
||||
}
|
||||
|
||||
export async function resolve (filepath, root, options) {
|
||||
if (!path.extname(filepath)) {
|
||||
filepath += options.extname
|
||||
}
|
||||
return lookup(filepath, root, options)
|
||||
}
|
||||
|
||||
export async function read (filepath) {
|
||||
return readFileAsync(filepath)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user