fix: preserve nested playlist paths when formatting

This commit is contained in:
chen zhihao
2026-08-31 20:52:37 +08:00
parent 8b84d0585d
commit 1b6b7db25a
4 changed files with 29 additions and 4 deletions
@@ -0,0 +1,5 @@
#EXTM3U
#EXTINF:-1 tvg-id="",Zulu (720p)
https://example.com/zulu.m3u8
#EXTINF:-1 tvg-id="",Alpha (720p)
https://example.com/alpha.m3u8
+12 -1
View File
@@ -30,7 +30,18 @@ describe('playlist:format', () => {
)
})
})
})
it('formats playlists in nested directories', () => {
fs.emptyDirSync('tests/__data__/output')
fs.copySync('tests/__data__/input/playlist_paths', 'tests/__data__/output/streams')
const cmd =
'cross-env STREAMS_DIR=tests/__data__/output/streams DATA_DIR=tests/__data__/input/data npm run playlist:format'
execSync(cmd, { encoding: 'utf8' })
const output = content('tests/__data__/output/streams/nested/nested.m3u')
expect(output.indexOf(',Alpha (720p)')).toBeLessThan(output.indexOf(',Zulu (720p)'))
})
})
function content(filepath: string) {
return fs.readFileSync(pathToFileURL(filepath), { encoding: 'utf8' })