diff options
Diffstat (limited to 'src/crawl-local.js')
-rwxr-xr-x | src/crawl-local.js | 23 |
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)) } |