« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src/crawl-local.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/crawl-local.js')
-rwxr-xr-xsrc/crawl-local.js12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/crawl-local.js b/src/crawl-local.js
index 91554af..3134193 100755
--- a/src/crawl-local.js
+++ b/src/crawl-local.js
@@ -56,7 +56,7 @@ function crawl(dirPath, extensions = [
     .then(filteredItems => ({items: filteredItems}))
 }
 
-async function main(args) {
+async function main(args, shouldReturn = false) {
   if (args.length === 0) {
     console.log("Usage: crawl-local /example/path [opts]")
     return
@@ -86,8 +86,14 @@ async function main(args) {
     'e': util => util.alias('-extensions')
   })
 
-  const res = await crawl(path, extensions)
-  console.log(JSON.stringify(res, null, 2))
+  const playlist = await crawl(path, extensions)
+
+  const str = JSON.stringify(playlist, null, 2)
+  if (shouldReturn) {
+    return str
+  } else {
+    console.log(str)
+  }
 }
 
 module.exports = {main, crawl}