summaryrefslogtreecommitdiff
path: root/packages/cli/src/utils/getFolderStructure.ts
diff options
context:
space:
mode:
authorTaylor Mullen <[email protected]>2025-04-18 17:47:49 -0400
committerN. Taylor Mullen <[email protected]>2025-04-18 17:51:16 -0400
commite7fa39112a9b528bfe5a36a7b8b806de645eb977 (patch)
treeec91ed950317d26b41674f08766bdb525bd5d43c /packages/cli/src/utils/getFolderStructure.ts
parentdfae3f62848f0c8c175f0e992a479c3bf49e50ed (diff)
Manually fix hooks and utils linting errors (partial)
- More changes are to come, this is truly a partial change in order to not disrupt as many people as possible. Part of https://b.corp.google.com/issues/411384603
Diffstat (limited to 'packages/cli/src/utils/getFolderStructure.ts')
-rw-r--r--packages/cli/src/utils/getFolderStructure.ts11
1 files changed, 5 insertions, 6 deletions
diff --git a/packages/cli/src/utils/getFolderStructure.ts b/packages/cli/src/utils/getFolderStructure.ts
index d1e780a8..8192fc96 100644
--- a/packages/cli/src/utils/getFolderStructure.ts
+++ b/packages/cli/src/utils/getFolderStructure.ts
@@ -1,5 +1,6 @@
import * as fs from 'fs/promises';
import * as path from 'path';
+import { getErrorMessage, isNodeError } from './errors.js';
const MAX_ITEMS = 200;
const TRUNCATION_INDICATOR = '...';
@@ -135,8 +136,8 @@ async function readFullStructure(
folderInfo.files.length +
folderInfo.subFolders.length +
folderInfo.subFolders.reduce((sum, sf) => sum + sf.totalChildren, 0);
- } catch (error: any) {
- if (error.code === 'EACCES' || error.code === 'ENOENT') {
+ } catch (error: unknown) {
+ if (isNodeError(error) && (error.code === 'EACCES' || error.code === 'ENOENT')) {
console.warn(
`Warning: Could not read directory ${folderPath}: ${error.message}`,
);
@@ -163,7 +164,6 @@ async function readFullStructure(
function reduceStructure(
fullInfo: FullFolderInfo,
maxItems: number,
- ignoredFolders: Set<string>, // Pass ignoredFolders for checking
): ReducedFolderNode {
const rootReducedNode: ReducedFolderNode = {
name: fullInfo.name,
@@ -348,7 +348,6 @@ export async function getFolderStructure(
const reducedRoot = reduceStructure(
fullInfo,
mergedOptions.maxItems,
- mergedOptions.ignoredFolders,
);
// 3. Count items in the *reduced* structure for the summary
@@ -377,8 +376,8 @@ export async function getFolderStructure(
`Showing ${reducedItemCount} of ${totalOriginalChildren} items (files + folders). ${disclaimer}`.trim();
return `${summary}\n\n${displayPath}/\n${structureLines.join('\n')}`;
- } catch (error: any) {
+ } catch (error: unknown) {
console.error(`Error getting folder structure for ${resolvedPath}:`, error);
- return `Error processing directory "${resolvedPath}": ${error.message}`;
+ return `Error processing directory "${resolvedPath}": ${getErrorMessage(error)}`;
}
}