Skip to main content

Glob

Fast file pattern matching tool that works with any codebase size using glob syntax.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.

Inputs

  • Pattern - string - Glob pattern to match files against, e.g., **/*.js, src/**/*.{ts,tsx} (required).
  • Path - string - Directory to search in (optional, defaults to current working directory).

Options

  • Max Results - int - Maximum number of results to return (default: 1000).
  • Include Hidden - bool - Include hidden files and directories (default: false).
  • Follow Symlinks - bool - Follow symbolic links (default: false).

Outputs

  • Matches - array - Array of matching file paths sorted by modification time (newest first). Each match includes:
    • path - Absolute path to the file
    • name - File name
    • size - File size in bytes
    • modTime - Last modification time (ISO 8601)
    • isDir - Whether this is a directory
  • Count - int - Number of matching files found.
  • Truncated - bool - Whether results were truncated due to max limit.

How It Works

The Glob node matches files and directories using glob patterns. When executed, the node:

  1. Validates the glob pattern
  2. Determines the search path (uses current directory if not specified)
  3. Walks the directory tree recursively
  4. For each file/directory:
    • Checks hidden file filter
    • Checks symlink settings
    • Matches against the glob pattern
    • Collects matching entries up to max results
  5. Sorts matches by modification time (newest first)
  6. Returns detailed file information for each match

Requirements

  • Valid glob pattern
  • Read access to search directory
  • Executable permissions on directories to traverse

Error Handling

The node will return specific errors in the following cases:

  • Missing pattern - "Pattern is required"
  • Empty pattern - "Pattern cannot be empty"
  • Path access error - "Cannot get current directory: {{error}}"
  • Invalid path - "Cannot resolve path: {{error}}"
  • Path not found - "Path not found: {{path}}"
  • Path not a directory - "Path must be a directory"
  • Invalid pattern - "Invalid glob pattern: {{error}}"
  • Search error - "Error searching files: {{error}}"

Usage Examples

Find All JavaScript Files

Pattern: **/*.js
Path: /home/user/project

Find TypeScript and TSX Files

Pattern: **/*.{ts,tsx}
Path: /home/user/src
Include Hidden: false

Find Configuration Files

Pattern: **/*.{json,yaml,yml}
Path: /home/user/app
Max Results: 100

Find Files in Specific Directory

Pattern: src/components/*.tsx
Path: /home/user/project

Find All Python Test Files

Pattern: **/*test*.py
Path: /home/user/tests

Find Recent Files

Pattern: **/*.log
Path: /var/logs
Max Results: 10

Results are sorted by modification time, so this returns the 10 most recent log files.

Glob Pattern Syntax

Wildcards

  • * - Matches any characters except path separator (/)
  • ** - Matches any characters including path separators (recursive)
  • ? - Matches exactly one character
  • [abc] - Matches any character in the set
  • [a-z] - Matches any character in the range
  • {a,b} - Matches either pattern a or pattern b

Examples

  • *.js - All .js files in current directory
  • **/*.js - All .js files recursively
  • src/**/*.test.js - All test.js files under src/
  • *.{js,ts} - All .js and .ts files in current directory
  • **/*.{json,yaml,yml} - All JSON and YAML files recursively
  • [A-Z]*.txt - Files starting with uppercase letter
  • file?.log - file1.log, fileA.log, but not file10.log

Usage Notes

  • Pattern matching uses forward slashes (/) regardless of OS
  • Hidden files/directories (starting with .) are skipped by default
  • Symlinks are not followed by default (prevents infinite loops)
  • Results are always sorted by modification time (newest first)
  • The search stops when max results is reached
  • Truncated flag indicates if more matches exist beyond the limit
  • All returned paths are absolute paths
  • Directories can also match if pattern allows
  • Pattern is matched against relative path from search root

Common Use Cases

Code Analysis

Find all source files of specific types for analysis.

Build Systems

Locate files that need to be compiled or processed.

Testing

Find all test files matching a pattern.

Documentation

Collect all documentation files (MD, TXT, etc.).

Configuration Management

Find configuration files across the project.

Asset Management

Locate image, CSS, or other asset files.

Best Practices

  • Use specific patterns to reduce search time
  • Set appropriate max results based on expected matches
  • Avoid overly broad patterns like **/* on large directories
  • Use file extensions to narrow results
  • Enable Include Hidden only when needed
  • Be cautious with Follow Symlinks to avoid loops
  • Check Truncated flag to know if results are incomplete
  • Use with Grep to search file contents after finding files

Performance Tips

  • Glob is optimized for speed - use it instead of shell ls or find
  • Pattern compilation is cached
  • Search stops immediately when max results is reached
  • Hidden file filtering happens during walk (not post-process)
  • Results are streamed, not collected entirely before sorting

Comparison with Other Nodes

  • Glob vs Grep: Glob matches file paths; Grep searches file contents
  • Glob vs LS: Glob uses patterns and recurses; LS lists single directory
  • Glob vs Read: Glob finds files; Read reads file content