« get me outta code hell

Update JS to have one main http-music command - 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:
authorliam4 <towerofnix@gmail.com>2017-07-20 18:55:18 -0300
committerliam4 <towerofnix@gmail.com>2017-07-20 18:55:18 -0300
commit1a02fe1688d66aea6277f61fcc305a6aed4e7d76 (patch)
tree6e64e928acf81af89fd7f0e802d94eb0c844a63e /src/crawl-local.js
parent2680ea9126499fb775b699f1dbd4ac9aacbc4e4a (diff)
Update JS to have one main http-music command
Diffstat (limited to 'src/crawl-local.js')
-rwxr-xr-xsrc/crawl-local.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/crawl-local.js b/src/crawl-local.js
index 6d245ae..629e015 100755
--- a/src/crawl-local.js
+++ b/src/crawl-local.js
@@ -30,13 +30,20 @@ function crawl(dirPath) {
   }).then(items => ({items}))
 }
 
-if (process.argv.length === 2) {
-  console.log("Usage: http-music-crawl-local /example/path..")
-  console.log("..or, npm run crawl-local /example/path")
-} else {
-  const path = process.argv[2]
-
-  crawl(path)
-    .then(res => console.log(JSON.stringify(res, null, 2)))
+async function main(args) {
+  if (args.length === 0) {
+    console.log("Usage: crawl-local /example/path")
+  } else {
+    const path = args[0]
+
+    const res = await crawl(path)
+    console.log(JSON.stringify(res, null, 2))
+  }
+}
+
+module.exports = main
+
+if (require.main === module) {
+  main(process.argv.slice(2))
     .catch(err => console.error(err))
 }