update fileTreeToObject method

This commit is contained in:
2017-04-30 15:37:34 +02:00
parent 06fb0acd52
commit a5b24a7c33
3 changed files with 29 additions and 22 deletions

View File

@ -209,13 +209,21 @@ export let toStringSync = function (filePath: string) {
}
export let fileTreeToObject = async (dirPathArg: string, miniMatchFilter: string) => {
let fileTree = await listFileTree(dirPathArg, miniMatchFilter)
// handle absolute miniMatchFilter
let dirPath: string
if (plugins.path.isAbsolute(miniMatchFilter)) {
dirPath = '/'
} else {
dirPath = dirPathArg
}
let fileTree = await listFileTree(dirPath, miniMatchFilter)
let smartfileArray: Smartfile[] = []
for (let filePath of fileTree) {
smartfileArray.push(new Smartfile({
path: filePath,
contentBuffer: new Buffer(toStringSync(
plugins.path.join(dirPathArg, filePath)
plugins.path.join(dirPath, filePath)
))
}))
}