« get me outta code hell

Fix top-level of locally crawled playlists to be a grouplike - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLiam <towerofnix@gmail.com>2017-07-16 09:06:04 -0400
committerLiam <towerofnix@gmail.com>2017-07-16 09:06:04 -0400
commit02059af9feea6326a76be2f5cf623d6ca86a4f78 (patch)
treeb5b78856a237c2e097145320b078d590ab03e4bb
parentd41eb1815c4c1614b0d3ecfdcda9eb41c20ea58d (diff)
Fix top-level of locally crawled playlists to be a grouplike
-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) {