« 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-http.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/crawl-http.js')
-rwxr-xr-xsrc/crawl-http.js9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/crawl-http.js b/src/crawl-http.js
index 4925f12..d3e1533 100755
--- a/src/crawl-http.js
+++ b/src/crawl-http.js
@@ -147,7 +147,7 @@ function getHTMLLinks(text) {
   })
 }
 
-async function main(args) {
+async function main(args, shouldReturn = false) {
   if (args.length === 0) {
     console.log("Usage: crawl-http http://.../example/path/ [opts]")
     return
@@ -202,7 +202,12 @@ async function main(args) {
     filterRegex: filterRegex
   })
 
-  console.log(JSON.stringify(downloadedPlaylist, null, 2))
+  const str = JSON.stringify(downloadedPlaylist, null, 2)
+  if (shouldReturn) {
+    return str
+  } else {
+    console.log(str)
+  }
 }
 
 module.exports = {main, crawl}