mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 21:00:40 -07:00
chore(TypeScript): fix unit tests and coverage
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import * as _ from '../util/underscore'
|
||||
import * as path from 'path'
|
||||
import { anySeries } from '../util/promise'
|
||||
import * as fs from 'fs'
|
||||
import { stat, readFile } from 'fs'
|
||||
|
||||
const statFileAsync = <(filepath: string) => Promise<object>>_.promisify(fs.stat)
|
||||
const readFileAsync = <(filepath: string, encoding: string) => Promise<string>>_.promisify(fs.readFile)
|
||||
export const fs = {
|
||||
stat: _.promisify(stat) as ((filepath: string) => Promise<object>),
|
||||
readFile: _.promisify(readFile) as ((filepath: string, encoding: string) => Promise<string>)
|
||||
}
|
||||
|
||||
export async function resolve (filepath, root, options) {
|
||||
if (!path.extname(filepath)) {
|
||||
@@ -15,7 +17,7 @@ export async function resolve (filepath, root, options) {
|
||||
const paths = root.map(root => path.resolve(root, filepath))
|
||||
return anySeries(paths, async path => {
|
||||
try {
|
||||
await statFileAsync(path)
|
||||
await fs.stat(path)
|
||||
return path
|
||||
} catch (e) {
|
||||
e.message = `${e.code}: Failed to lookup ${filepath} in: ${root}`
|
||||
@@ -25,5 +27,5 @@ export async function resolve (filepath, root, options) {
|
||||
}
|
||||
|
||||
export async function read (filepath): Promise<string> {
|
||||
return readFileAsync(filepath, 'utf8')
|
||||
return fs.readFile(filepath, 'utf8')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user