mirror of
https://github.com/FreeTubeApp/FreeTube.git
synced 2025-12-05 01:10:31 +00:00
Clean up defunct shaka-player types patching (#8224)
This commit is contained in:
@@ -1,60 +1,12 @@
|
||||
// This script fixes shaka not exporting its type definitions and referencing the Roboto font on google fonts in its CSS
|
||||
// by adding an export line to the type definitions and updating the CSS to point to the local Roboto font
|
||||
// This script fixes shaka-player referencing the Roboto font on google fonts in its CSS
|
||||
// by updating the CSS to point to the local Roboto font
|
||||
// this script only makes changes if they are needed, so running it multiple times doesn't cause any problems
|
||||
|
||||
import { appendFileSync, closeSync, ftruncateSync, openSync, readFileSync, writeSync } from 'fs'
|
||||
import { closeSync, ftruncateSync, openSync, readFileSync, writeSync } from 'fs'
|
||||
import { resolve } from 'path'
|
||||
|
||||
const SHAKA_DIST_DIR = resolve(import.meta.dirname, '../node_modules/shaka-player/dist')
|
||||
|
||||
function fixTypes() {
|
||||
let fixedTypes = false
|
||||
|
||||
let fileHandleNormal
|
||||
try {
|
||||
fileHandleNormal = openSync(`${SHAKA_DIST_DIR}/shaka-player.ui.d.ts`, 'a+')
|
||||
|
||||
const contents = readFileSync(fileHandleNormal, 'utf-8')
|
||||
|
||||
// This script is run after every `yarn install`, even if shaka-player wasn't updated
|
||||
// So we want to check first, if we actually need to make any changes
|
||||
// or if the ones from the previous run are still intact
|
||||
if (!contents.includes('export default shaka')) {
|
||||
appendFileSync(fileHandleNormal, 'export default shaka;\n')
|
||||
|
||||
fixedTypes = true
|
||||
}
|
||||
} finally {
|
||||
if (typeof fileHandleNormal !== 'undefined') {
|
||||
closeSync(fileHandleNormal)
|
||||
}
|
||||
}
|
||||
|
||||
let fileHandleDebug
|
||||
try {
|
||||
fileHandleDebug = openSync(`${SHAKA_DIST_DIR}/shaka-player.ui.debug.d.ts`, 'a+')
|
||||
|
||||
const contents = readFileSync(fileHandleDebug, 'utf-8')
|
||||
|
||||
// This script is run after every `yarn install`, even if shaka-player wasn't updated
|
||||
// So we want to check first, if we actually need to make any changes
|
||||
// or if the ones from the previous run are still intact
|
||||
if (!contents.includes('export default shaka')) {
|
||||
appendFileSync(fileHandleDebug, 'export default shaka;\n')
|
||||
|
||||
fixedTypes = true
|
||||
}
|
||||
} finally {
|
||||
if (typeof fileHandleDebug !== 'undefined') {
|
||||
closeSync(fileHandleDebug)
|
||||
}
|
||||
}
|
||||
|
||||
if (fixedTypes) {
|
||||
console.log('Fixed shaka-player types')
|
||||
}
|
||||
}
|
||||
|
||||
function removeRobotoFont() {
|
||||
let cssFileHandle
|
||||
try {
|
||||
@@ -72,11 +24,10 @@ function removeRobotoFont() {
|
||||
console.log('Removed shaka-player Roboto font, so it uses ours')
|
||||
}
|
||||
} finally {
|
||||
if (typeof cssFileHandle !== 'undefined') {
|
||||
if (cssFileHandle !== undefined) {
|
||||
closeSync(cssFileHandle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fixTypes()
|
||||
removeRobotoFont()
|
||||
|
||||
Reference in New Issue
Block a user