Update file.js
This commit is contained in:
parent
2ef6b1623e
commit
02447d306d
10
src/file.js
10
src/file.js
|
@ -1,6 +1,8 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
|
||||
module.exports.list = list
|
||||
module.exports.read = read
|
||||
module.exports.write = write
|
||||
module.exports.resolve = resolve
|
||||
|
@ -9,6 +11,14 @@ module.exports.dirname = dirname
|
|||
module.exports.templateVariables = templateVariables
|
||||
module.exports.templateFormat = templateFormat
|
||||
|
||||
function list(pattern) {
|
||||
return new Promise(resolve => {
|
||||
glob(pattern, function (err, files) {
|
||||
resolve(files)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function read(filepath) {
|
||||
return fs.readFileSync(path.resolve(filepath), { encoding: 'utf-8' })
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue