From 02c6157c7ca354281021d528c64150221bbd28c5 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 6 Sep 2018 11:41:39 -0400 Subject: [PATCH 1/2] Add saveFile Multiples This catches when there's a fileset rather than just an individual file returned. --- lib/index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 72e3377..4a82dc3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -153,11 +153,15 @@ const flattenChildItems = (currentTier, flatData) => { }) } + const saveFiles = (opts, done) => { const filesSaved = [] - filesToSave.forEach(file => { + function saveFile(file) { const src = file.src const origin = file.origin + if (!src) { + console.log(file) + } const fileName = src.substr(src.lastIndexOf('/') + 1, src.length) const destFileName = `${opts.filePath}/${fileName}` mkdirp.sync(`${process.cwd()}/${opts.filePath}`) @@ -170,6 +174,17 @@ const saveFiles = (opts, done) => { done() } }) + } + + filesToSave.forEach(file => { + if (file instanceof Array) { + for (let individualFile of file) { + saveFile(individualFile) + } + } + else { + saveFile(file) + } }) } From ebefa6ed100007d8ed266e5300a3555a1cb12ed9 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Thu, 6 Sep 2018 12:50:12 -0400 Subject: [PATCH 2/2] Fix xo --- lib/index.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/index.js b/lib/index.js index 3248345..3a6afdd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -153,7 +153,6 @@ const flattenChildItems = (currentTier, flatData) => { }) } - const saveFiles = (opts, done) => { const filesSaved = [] function saveFile(file) { @@ -173,12 +172,11 @@ const saveFiles = (opts, done) => { } filesToSave.forEach(file => { - if (file instanceof Array) { - for (let individualFile of file) { + if (Array.isArray(file)) { + for (const individualFile of file) { saveFile(individualFile) } - } - else { + } else { saveFile(file) } })