Skip to content

ashuvssut/fs-event-action

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fs-event-action

Run a cancellable asynchronous action triggered via file system (FS) events.

  • Utilizes chokidar to monitor FS events in a directory.
  • Upon any FS event, a "Cancellable" action is initiated. The cancellable action is crafted using c-promise2.
    • Explore CodeSandbox examples in the c-promise2 repository to understand its usage.
    • Refer to this video for insights into how generator/yield is employed to write async/await logic.
      • Generator functions are employed by c-promise2 to create cancellable asynchronous routines.
    • A custom ShellProcess class is available in src/utils/ShellProcess.ts for executing cancellable terminal commands.

Usage

  • Run development script: yarn dev
  • Build script: yarn build
    • Outputs to /dist

Create Your Own Event Action

  • Refer to src/event-action.example.ts for an example demonstrating how to create cancellable logic.
  • Subsequent triggers of the Event Action will cancel the previously triggered Event Action if it is still running.

Demo

Kapture.2024-01-12.at.09.58.09.mp4

Further Development

  • The current examples may have incomplete TypeScript type definitions due to the absence of type definitions for the c-promise2 library.

About

Run a cancellable async action on FS events

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published