fix: resolve ensemble build type errors
This commit is contained in:
parent
f6d3ef3ec1
commit
cb0b7a04ca
@ -9,7 +9,7 @@
|
|||||||
* - Packages with more than MAX_FILE_COUNT files throw an error
|
* - 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 { join, extname, relative } from 'node:path';
|
||||||
import { createLogger } from '../../shared/utils/debug.js';
|
import { createLogger } from '../../shared/utils/debug.js';
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ export function isAllowedExtension(filename: string): boolean {
|
|||||||
*/
|
*/
|
||||||
function shouldCopyFile(
|
function shouldCopyFile(
|
||||||
filePath: string,
|
filePath: string,
|
||||||
stats: ReturnType<typeof lstatSync>,
|
stats: Stats,
|
||||||
): boolean {
|
): boolean {
|
||||||
if (stats.size > MAX_FILE_SIZE) return false;
|
if (stats.size > MAX_FILE_SIZE) return false;
|
||||||
if (!isAllowedExtension(filePath)) return false;
|
if (!isAllowedExtension(filePath)) return false;
|
||||||
@ -66,9 +66,9 @@ function collectFromDir(
|
|||||||
packageRoot: string,
|
packageRoot: string,
|
||||||
targets: CopyTarget[],
|
targets: CopyTarget[],
|
||||||
): void {
|
): void {
|
||||||
let entries: ReturnType<typeof readdirSync>;
|
let entries: string[];
|
||||||
try {
|
try {
|
||||||
entries = readdirSync(dir);
|
entries = readdirSync(dir, 'utf-8');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.debug('Failed to read directory', { dir, err });
|
log.debug('Failed to read directory', { dir, err });
|
||||||
return;
|
return;
|
||||||
@ -114,14 +114,14 @@ export function collectCopyTargets(packageRoot: string): CopyTarget[] {
|
|||||||
|
|
||||||
for (const allowedDir of ALLOWED_DIRS) {
|
for (const allowedDir of ALLOWED_DIRS) {
|
||||||
const dirPath = join(packageRoot, allowedDir);
|
const dirPath = join(packageRoot, allowedDir);
|
||||||
let stats: ReturnType<typeof lstatSync>;
|
let stats: Stats | undefined;
|
||||||
try {
|
try {
|
||||||
stats = lstatSync(dirPath);
|
stats = lstatSync(dirPath);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.debug('Directory not accessible, skipping', { dirPath, err });
|
log.debug('Directory not accessible, skipping', { dirPath, err });
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!stats.isDirectory()) continue;
|
if (!stats?.isDirectory()) continue;
|
||||||
|
|
||||||
collectFromDir(dirPath, packageRoot, targets);
|
collectFromDir(dirPath, packageRoot, targets);
|
||||||
|
|
||||||
|
|||||||
@ -38,14 +38,16 @@ export function parseTarVerboseListing(lines: string[]): TarVerboseListing {
|
|||||||
let firstDirEntry = '';
|
let firstDirEntry = '';
|
||||||
const includePaths: string[] = [];
|
const includePaths: string[] = [];
|
||||||
|
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (const [i, line] of lines.entries()) {
|
||||||
const line = lines[i];
|
if (!line) continue;
|
||||||
const type = line[0];
|
const type = line[0];
|
||||||
|
|
||||||
const match = TAR_VERBOSE_PATH_RE.exec(line);
|
const match = TAR_VERBOSE_PATH_RE.exec(line);
|
||||||
if (!match) continue;
|
if (!match) continue;
|
||||||
|
const pathPart = match[1];
|
||||||
|
if (!pathPart) continue;
|
||||||
|
|
||||||
const archivePath = match[1].trim();
|
const archivePath = pathPart.trim();
|
||||||
|
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
firstDirEntry = archivePath.replace(/\/$/, '');
|
firstDirEntry = archivePath.replace(/\/$/, '');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user