Chore: fix android build

This commit is contained in:
Pieter Vander Vennet 2025-05-03 15:23:17 +02:00
parent 07d5c85971
commit 82905fee3f
3 changed files with 23 additions and 8 deletions

View file

@ -18,7 +18,7 @@ export default class ScriptUtils {
* @param path
* @param maxDepth
*/
public static readDirRecSync(path, maxDepth = 999): string[] {
public static readDirRecSync(path: string, maxDepth = 999): string[] {
const result: string[] = []
if (maxDepth <= 0) {
return []
@ -28,7 +28,6 @@ export default class ScriptUtils {
const stats = lstatSync(fullEntry)
if (stats.isDirectory()) {
// Subdirectory
// @ts-ignore
result.push(...ScriptUtils.readDirRecSync(fullEntry, maxDepth - 1))
} else {
result.push(fullEntry)
@ -37,6 +36,23 @@ export default class ScriptUtils {
return result
}
public static createParentDir(path: string) {
const index = path.lastIndexOf("/")
if (index < 0) {
return
}
const parent = path.substring(0, index)
if (parent.length === 0) {
return
}
if (fs.existsSync(parent)) {
return
}
fs.mkdirSync(parent, {
recursive: true
})
}
public static DownloadFileTo(url, targetFilePath: string): Promise<void> {
ScriptUtils.erasableLog("Downloading", url, "to", targetFilePath)
return new Promise<void>((resolve) => {
@ -216,7 +232,6 @@ export default class ScriptUtils {
const parts: string[] = []
res.setEncoding("utf8")
res.on("data", function (chunk) {
// @ts-ignore
parts.push(chunk)
})