diff options
-rwxr-xr-x | src/play.js | 2 | ||||
-rw-r--r-- | src/smart-playlist.js | 10 |
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)) |