mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-23 13:51:20 -08:00
test(ci): [CI-TYPES-01] validate installed Audio and HLS types
This commit is contained in:
1 parent
210484c443
commit
00c131bff1
16 files changed
+1246
-12
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { createHash } from 'node:crypto'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { checkTypeFixture, typeMatrix } from './types.ts'
|
||||
|
||||
const fixtures: Record<string, string> = {
|
||||
'artplayer-plugin-audio-track': 'audio-track.ts',
|
||||
'artplayer-plugin-hls-control': 'hls-control.ts',
|
||||
}
|
||||
|
||||
export function installedPluginTypes(directory: string, packages: string[]) {
|
||||
const results = []
|
||||
for (const name of packages) {
|
||||
const fixture = fixtures[name]
|
||||
if (!fixture)
|
||||
continue
|
||||
const source = fs.readFileSync(fileURLToPath(new URL(`../../test/types/${fixture}`, import.meta.url)), 'utf8')
|
||||
const modes = typeMatrix.map(({ compiler, mode }) => checkTypeFixture(directory, source, compiler, mode))
|
||||
for (const result of modes)
|
||||
assert(result.declarations.some(file => file.startsWith(`node_modules/${name}/`)), `Missing installed declaration for ${name}`)
|
||||
results.push({ name, fixture: path.posix.join('test/types', fixture), fixtureSha256: createHash('sha256').update(source).digest('hex'), modes })
|
||||
}
|
||||
return results
|
||||
}
|
||||
Reference in new issue
Block a user