Skip to content

Commit

Permalink
#844 - Exclude hidden files and verify if valid
Browse files Browse the repository at this point in the history
  • Loading branch information
estruyf committed Sep 19, 2024
1 parent 6588b90 commit 0110b73
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/helpers/processFilePrefixPlaceholders.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { FileType, Uri, workspace } from 'vscode';
import { parse } from 'path';
import { isValidFile } from './isValidFile';

/**
* Processes file prefix placeholders in a given string value.
Expand All @@ -15,7 +16,13 @@ export const processFilePrefixPlaceholders = async (value: string, folderPath?:
// Example: {{filePrefix.index}} or {{filePrefix.index|chars:4,zeros:true}}
if (value && value.includes('{{filePrefix.index') && folderPath) {
const dirContent = await workspace.fs.readDirectory(Uri.file(folderPath));
const files = dirContent.filter(([_, type]) => type === FileType.File);
const files = dirContent.filter(
([filePath, type]) =>
type === FileType.File &&
!filePath.startsWith('.') &&
isValidFile(filePath) &&
!filePath.includes('_index.')
);

let chars = 3;
let idxValue = files.length + 1;
Expand Down

0 comments on commit 0110b73

Please sign in to comment.