From aac119f2162dc981fa4b6fcba5e8301e7625a011 Mon Sep 17 00:00:00 2001 From: Florrie Date: Wed, 25 Oct 2017 09:26:53 -0300 Subject: Make -k and -x fail when the passed group path is not perfectly found --- src/play.js | 5 ++++- src/playlist-utils.js | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/play.js b/src/play.js index 8f52e63..c754836 100755 --- a/src/play.js +++ b/src/play.js @@ -302,7 +302,10 @@ async function main(args) { const pathString = util.nextArg() const group = filterPlaylistByPathString(sourcePlaylist, pathString) - activePlaylist.items.push(group) + + if (group) { + activePlaylist.items.push(group) + } }, 'k': util => util.alias('-keep'), diff --git a/src/playlist-utils.js b/src/playlist-utils.js index a75008a..d19c571 100644 --- a/src/playlist-utils.js +++ b/src/playlist-utils.js @@ -261,7 +261,7 @@ function filterGrouplikeByPath(grouplike, pathParts) { } } else { console.warn(`Not found: "${pathParts[0]}"`) - return grouplike + return null } } @@ -276,6 +276,10 @@ function removeGroupByPath(playlist, pathParts) { const groupToRemove = filterGrouplikeByPath(playlist, pathParts) + if (groupToRemove === null) { + return + } + if (playlist === groupToRemove) { console.error( 'You can\'t remove the playlist from itself! Instead, try --clear' + -- cgit 1.3.0-6-gf8a5