From 1a02fe1688d66aea6277f61fcc305a6aed4e7d76 Mon Sep 17 00:00:00 2001 From: liam4 Date: Thu, 20 Jul 2017 18:55:18 -0300 Subject: Update JS to have one main http-music command --- src/crawl-local.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src/crawl-local.js') 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)) } -- cgit 1.3.0-6-gf8a5