Update file.js

This commit is contained in:
freearhey 2023-07-09 16:30:55 +03:00
parent 2ef6b1623e
commit 02447d306d
1 changed files with 10 additions and 0 deletions

View File

@ -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' })
}