refactor: move fs util into template.js

This commit is contained in:
Jun Yang
2018-10-01 22:06:03 +08:00
parent 5412c5a39f
commit 8a629980d9
3 changed files with 9 additions and 18 deletions
+6 -2
View File
@@ -1,7 +1,11 @@
import * as _ from './util/underscore.js'
import path from 'path'
import {anySeries} from './util/promise.js'
import {statFileAsync, readFileAsync} from './util/fs.js'
import fs from 'fs'
import {promisify} from 'util'
const statFileAsync = promisify(fs.stat)
const readFileAsync = promisify(fs.readFile)
export async function resolve (filepath, root, options) {
if (!path.extname(filepath)) {
@@ -22,5 +26,5 @@ export async function resolve (filepath, root, options) {
}
export async function read (filepath) {
return readFileAsync(filepath)
return readFileAsync(filepath, 'utf8')
}