From cb0b7a04cafc2fea65f1768300a65ea014248717 Mon Sep 17 00:00:00 2001 From: nrslib <38722970+nrslib@users.noreply.github.com> Date: Sun, 22 Feb 2026 02:19:18 +0900 Subject: [PATCH] fix: resolve ensemble build type errors --- src/features/ensemble/file-filter.ts | 12 ++++++------ src/features/ensemble/tar-parser.ts | 8 +++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/features/ensemble/file-filter.ts b/src/features/ensemble/file-filter.ts index 0d8ce0f..c39c980 100644 --- a/src/features/ensemble/file-filter.ts +++ b/src/features/ensemble/file-filter.ts @@ -9,7 +9,7 @@ * - Packages with more than MAX_FILE_COUNT files throw an error */ -import { lstatSync, readdirSync } from 'node:fs'; +import { lstatSync, readdirSync, type Stats } from 'node:fs'; import { join, extname, relative } from 'node:path'; import { createLogger } from '../../shared/utils/debug.js'; @@ -50,7 +50,7 @@ export function isAllowedExtension(filename: string): boolean { */ function shouldCopyFile( filePath: string, - stats: ReturnType, + stats: Stats, ): boolean { if (stats.size > MAX_FILE_SIZE) return false; if (!isAllowedExtension(filePath)) return false; @@ -66,9 +66,9 @@ function collectFromDir( packageRoot: string, targets: CopyTarget[], ): void { - let entries: ReturnType; + let entries: string[]; try { - entries = readdirSync(dir); + entries = readdirSync(dir, 'utf-8'); } catch (err) { log.debug('Failed to read directory', { dir, err }); return; @@ -114,14 +114,14 @@ export function collectCopyTargets(packageRoot: string): CopyTarget[] { for (const allowedDir of ALLOWED_DIRS) { const dirPath = join(packageRoot, allowedDir); - let stats: ReturnType; + let stats: Stats | undefined; try { stats = lstatSync(dirPath); } catch (err) { log.debug('Directory not accessible, skipping', { dirPath, err }); continue; } - if (!stats.isDirectory()) continue; + if (!stats?.isDirectory()) continue; collectFromDir(dirPath, packageRoot, targets); diff --git a/src/features/ensemble/tar-parser.ts b/src/features/ensemble/tar-parser.ts index 09a3050..851b3a0 100644 --- a/src/features/ensemble/tar-parser.ts +++ b/src/features/ensemble/tar-parser.ts @@ -38,14 +38,16 @@ export function parseTarVerboseListing(lines: string[]): TarVerboseListing { let firstDirEntry = ''; const includePaths: string[] = []; - for (let i = 0; i < lines.length; i++) { - const line = lines[i]; + for (const [i, line] of lines.entries()) { + if (!line) continue; const type = line[0]; const match = TAR_VERBOSE_PATH_RE.exec(line); if (!match) continue; + const pathPart = match[1]; + if (!pathPart) continue; - const archivePath = match[1].trim(); + const archivePath = pathPart.trim(); if (i === 0) { firstDirEntry = archivePath.replace(/\/$/, '');