« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/crawl-local.js8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/crawl-local.js b/src/crawl-local.js
index cf5db87..6d245ae 100755
--- a/src/crawl-local.js
+++ b/src/crawl-local.js
@@ -19,17 +19,15 @@ function crawl(dirPath) {
 
       return stat(itemPath).then(stats => {
         if (stats.isDirectory()) {
-          return crawl(itemPath).then(contents => {
-            const group = {name: item, items: contents}
-            return group
-          })
+          return crawl(itemPath)
+            .then(group => Object.assign(group, {name: item}))
         } else if (stats.isFile()) {
           const track = {name: item, downloaderArg: itemPath}
           return track
         }
       })
     }))
-  })
+  }).then(items => ({items}))
 }
 
 if (process.argv.length === 2) {