Documentation
    Preparing search index...

    Exposes an intutive API to run actions when different kind of files are changed. The FileSystem is built around the vocabulary used by AdonisJS. Which includes:

    • Source files: TypeScript, JavaScript, JSON, JSX, TSX files that are included inside the "tsconfig.json" file are considered as source files.
    • Meta files: Files registered under the "metaFiles" array of "adonisrc.ts" file are called meta files.
    • Meta restart files: Meta files with "restart: true" enabled are called meta restart files.

    Using FileSystem you can register actions to be executed when a file changes in one of the above categories.

    const fs = new FileSystem(cwd, tsConfig, rcFile)
    const file = fs.inspect('./app/controllers/users_controller.ts')
    Index

    Constructors

    • Create a new FileSystem instance

      Parameters

      • cwd: string | URL

        The current working directory URL or string path

      • tsConfig: ParsedCommandLine

        Parsed TypeScript configuration

      • rcFile: AssemblerRcFile

        AdonisJS RC file configuration

      Returns FileSystem

    Properties

    inspect: (input: string, ...args: [string?]) => null | InspectedFile = ...

    Inspect a file path to determine its type and properties within the project.

    This method analyzes a file to categorize it as a script file, test file, or meta file, and determines whether changes to the file should trigger server restarts. Results are memoized for performance optimization.

    Type Declaration

      • (input: string, ...args: [string?]): null | InspectedFile
      • Parameters

        • input: string
        • ...args: [string?]

        Returns null | InspectedFile

        File inspection result or null if the file should be ignored

    const file = fileSystem.inspect('/project/app/models/user.ts', 'app/models/user.ts')
    if (file) {
    console.log(file.fileType) // 'script'
    console.log(file.reloadServer) // true
    }
    shouldWatchDirectory: (input: string, ...args: []) => unknown = ...

    Determines if a directory should be watched by the file watcher.

    This method checks if a directory should be monitored for file changes based on the TypeScript configuration includes/excludes patterns. Results are memoized for performance. Chokidar sends absolute Unix paths.

    Note: Use shouldWatchFile for files and this method for directories only.

    Type Declaration

      • (input: string, ...args: []): unknown
      • Parameters

        • input: string
        • ...args: []

        Returns unknown

        True if the directory should be watched

    const shouldWatch = fileSystem.shouldWatchDirectory('/project/app/controllers')
    console.log(shouldWatch) // true

    Accessors

    • get includes(): string[]

      Includes glob patterns extracted from "tsconfig.json" file. Defaults to: ["**/*"]

      Returns string[]

    • get excludes(): string[]

      Excludes glob patterns extracted from "tsconfig.json" file.

      Defaults to: [ 'node_modules/', 'bower_components/', 'jspm_packages/**, ]

      Following patterns are always ignored

      '.git/', 'coverage/', '.github/**'

      Returns string[]

    Methods

    • Returns true if the file should be watched. Chokidar sends absolute unix paths to the ignored callback.

      You must use "shouldWatchDirectory" method for directories and call this method for files only.

      Parameters

      • absolutePath: string

        The absolute path to the file

      Returns boolean

      True if the file should be watched