Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/parser/extractTodosFromDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { extractTodosFromFile } from './extractTodos';
import { TodoItem } from './types';

const SUPPORTED_EXTENSIONS = ['.ts', '.js', '.py', '.go', '.java', '.rb', '.sh', '.html', '.xml'];
const IGNORED_DIRS = ['node_modules', 'dist', 'coverage'];

export function extractTodosFromDir(dirPath: string): TodoItem[] {
const todos: TodoItem[] = [];
Expand All @@ -15,6 +16,7 @@ export function extractTodosFromDir(dirPath: string): TodoItem[] {
const fullPath = path.join(currentPath, entry.name);

if (entry.isDirectory()) {
if (IGNORED_DIRS.includes(entry.name)) continue;
walk(fullPath);
} else if (entry.isFile()) {
const ext = path.extname(entry.name);
Expand Down
5 changes: 4 additions & 1 deletion src/parser/extractTodosWithStructuredTagsFromDir.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import path from 'path';
import fs from 'fs';
import { TodoItem } from './types';
import { extractTodosWithStructuredTags } from './extractTodosWithStructuredTags';
import { isTextFile } from '../utils/isTextFile';
import { isTextFile } from '../utils/isTextFile';

const IGNORED_DIRS = ['node_modules', 'dist', 'coverage'];


export function extractTodosWithStructuredTagsFromDir(dir: string): TodoItem[] {
Expand All @@ -15,6 +17,7 @@ export function extractTodosWithStructuredTagsFromDir(dir: string): TodoItem[] {
for (const entry of entries) {
const fullPath = path.join(currentPath, entry.name);
if (entry.isDirectory()) {
if (IGNORED_DIRS.includes(entry.name)) continue;
walk(fullPath);
} else if (entry.isFile()) {
try {
Expand Down
6 changes: 6 additions & 0 deletions tests/extractTodosFromDir.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ describe('extractTodosFromDir', () => {
expect(typeof one?.line).toBe('number');
expect(one?.line).toBeGreaterThan(0);
});

it('should ignore files inside ignored directories', () => {
const todos = extractTodosFromDir(base);
const ignored = todos.find(t => t.text.includes('Should not be picked up'));
expect(ignored).toBeUndefined();
});
});
2 changes: 2 additions & 0 deletions tests/fixtures/node_modules/ignore.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.