« get me outta code hell

Publish smart-playlist command properly - http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2017-11-27 22:00:11 -0400
committerFlorrie <towerofnix@gmail.com>2017-11-27 22:00:11 -0400
commit31692325a13be15d75d739c34ab47047ac45fde2 (patch)
tree51e64585dddcf0148a87677274df3211858afbdf /src
parentef947f88f6fb084cbc97f89ffffcf93561ba93a5 (diff)
Publish smart-playlist command properly
Diffstat (limited to 'src')
-rwxr-xr-xsrc/play.js2
-rw-r--r--src/smart-playlist.js10
2 files changed, 6 insertions, 6 deletions
diff --git a/src/play.js b/src/play.js
index c910b08..5b71c94 100755
--- a/src/play.js
+++ b/src/play.js
@@ -11,7 +11,7 @@ const commandExists = require('./command-exists')
 const startLoopPlay = require('./loop-play')
 const processArgv = require('./process-argv')
 const promisifyProcess = require('./promisify-process')
-const processSmartPlaylist = require('./smart-playlist')
+const { processSmartPlaylist } = require('./smart-playlist')
 
 const {
   filterPlaylistByPathString, removeGroupByPathString, getPlaylistTreeString,
diff --git a/src/smart-playlist.js b/src/smart-playlist.js
index 76cd877..4d20e80 100644
--- a/src/smart-playlist.js
+++ b/src/smart-playlist.js
@@ -6,7 +6,7 @@ const { getCrawlerByName } = require('./crawlers')
 const { promisify } = require('util')
 const readFile = promisify(fs.readFile)
 
-async function processItem(item) {
+async function processSmartPlaylist(item) {
   // Object.assign is used so that we keep original properties, e.g. "name"
   // or "apply". (It's also used so we return copies of original objects.)
 
@@ -25,15 +25,13 @@ async function processItem(item) {
     return Object.assign({}, item, await crawl(...args))
   } else if ('items' in item) {
     return Object.assign({}, item, {
-      items: await Promise.all(item.items.map(processItem))
+      items: await Promise.all(item.items.map(processSmartPlaylist))
     })
   } else {
     return Object.assign({}, item)
   }
 }
 
-module.exports = processItem
-
 async function main(opts) {
   // TODO: Error when no file is given
 
@@ -41,10 +39,12 @@ async function main(opts) {
     console.log("Usage: smart-playlist /path/to/playlist")
   } else {
     const playlist = JSON.parse(await readFile(opts[0]))
-    console.log(JSON.stringify(await processItem(playlist), null, 2))
+    console.log(JSON.stringify(await processSmartPlaylist(playlist), null, 2))
   }
 }
 
+module.exports = Object.assign(main, {processSmartPlaylist})
+
 if (require.main === module) {
   main(process.argv.slice(2))
     .catch(err => console.error(err))