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 fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const glob = require('glob')
|
||||||
|
|
||||||
|
module.exports.list = list
|
||||||
module.exports.read = read
|
module.exports.read = read
|
||||||
module.exports.write = write
|
module.exports.write = write
|
||||||
module.exports.resolve = resolve
|
module.exports.resolve = resolve
|
||||||
|
@ -9,6 +11,14 @@ module.exports.dirname = dirname
|
||||||
module.exports.templateVariables = templateVariables
|
module.exports.templateVariables = templateVariables
|
||||||
module.exports.templateFormat = templateFormat
|
module.exports.templateFormat = templateFormat
|
||||||
|
|
||||||
|
function list(pattern) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
glob(pattern, function (err, files) {
|
||||||
|
resolve(files)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function read(filepath) {
|
function read(filepath) {
|
||||||
return fs.readFileSync(path.resolve(filepath), { encoding: 'utf-8' })
|
return fs.readFileSync(path.resolve(filepath), { encoding: 'utf-8' })
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue