Skip to content

iAmNathanJ/fs-poll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fs-poll

A simple, polling file watcher for Deno. Probably don't use this. Deno will support fsEvents in the very near future.

import { watch } from "https://denopkg.com/iamnathanj/fs-poll@v1.3.0/mod.ts";

Usage

// default mode
// use this for directories that don't change rapidly, like src/
watch({
  handle: fileChange => {
    // fileChange will have the shape:
    {
      type: "created" | "modified" | "removed",
      path: string;
    }
  }
});
// batch mode
// use this for directories that change often, like dist/
watch({
  batch: true,
  handle: fileChanges => {
    // fileChanges will have the shape:
    {
      created?: path[],
      modified?: path[],
      removed?: path[],
    }
  }
});

Options

(defaults shown)

{
  handle: (FileEvent | FileEventBatch) => void,
  root?: string; // Deno.cwd()
  batch?: boolean // false
  interval?: number; // 100
  walkOptions?: WalkOptions; // see below
}

walkOptions are passed directly to std/fs/walk.ts with the following defaults:

{
  includeDirs: false,
  exts: [".js", ".ts", ".tsx"]
}

About

A simple file watcher for Deno

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published