This commit is contained in:
Philipp Kunz 2017-05-01 19:49:34 +02:00
parent dcc85a56b8
commit 9fc581b866
5 changed files with 16 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@ -40,7 +40,7 @@
"vinyl-file": "^3.0.0" "vinyl-file": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {
"gulp-function": "^2.2.3", "gulp-function": "^2.2.9",
"tapbundle": "^1.0.10" "tapbundle": "^1.0.10"
} }
} }

View File

@ -51,8 +51,9 @@ tap.test('.fs.listFileTree() -> should get a file tree', async () => {
expect(folderArrayArg).to.not.deep.include('mytest.json') expect(folderArrayArg).to.not.deep.include('mytest.json')
}) })
tap.test('.fs.toObjectFromFileTree -> should read a file tree into an Object', async () => { tap.test('.fs.fileTreeToObject -> should read a file tree into an Object', async () => {
let fileArrayArg = await smartfile.fs.fileTreeToObject(path.resolve('./test/'), '**/*.txt') let fileArrayArg = await smartfile.fs.fileTreeToObject(path.resolve('./test/'), '**/*.txt')
expect(fileArrayArg[0].contents.toString()).to.not.be.null
// expect(fileArrayArg[1]).to.be.instanceof(smartfile.Smartfile) // expect(fileArrayArg[1]).to.be.instanceof(smartfile.Smartfile)
}) })

View File

@ -220,10 +220,13 @@ export let fileTreeToObject = async (dirPathArg: string, miniMatchFilter: string
let fileTree = await listFileTree(dirPath, miniMatchFilter) let fileTree = await listFileTree(dirPath, miniMatchFilter)
let smartfileArray: Smartfile[] = [] let smartfileArray: Smartfile[] = []
for (let filePath of fileTree) { for (let filePath of fileTree) {
let fileContentString = toStringSync(
plugins.path.join(dirPath, filePath)
)
// push a read file as Smartfile
smartfileArray.push(new Smartfile({ smartfileArray.push(new Smartfile({
contentBuffer: new Buffer(toStringSync( contentBuffer: new Buffer(fileContentString),
plugins.path.join(dirPath, filePath)
)),
base: dirPath, base: dirPath,
path: filePath path: filePath
})) }))

View File

@ -186,9 +186,9 @@ graceful-fs@^4.1.2, graceful-fs@^4.1.6:
version "4.1.11" version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
gulp-function@^2.2.3: gulp-function@^2.2.9:
version "2.2.6" version "2.2.9"
resolved "https://registry.yarnpkg.com/gulp-function/-/gulp-function-2.2.6.tgz#e14c1eefdab4d4ac11d9f4abfdbe94115a12d10d" resolved "https://registry.yarnpkg.com/gulp-function/-/gulp-function-2.2.9.tgz#de513103db9d817e94bb8aab45f30bf286f19ae5"
dependencies: dependencies:
"@types/through2" "^2.0.32" "@types/through2" "^2.0.32"
smartq "^1.1.1" smartq "^1.1.1"