Skip to content

Repository files navigation

@write-for-christ/prophet-samuel

In the Bible, prophet Samuel always listen for God's Word before doing something, this module will help us listen for files changed and execute actions in reactive way.

Build Status Coverage Status David David Commitizen friendly Greenkeeper badge

Features

  • Watch for all files changed.
  • Parse file path from changed file.
  • Execute actions based on filtered pattern.
  • Support reactive functional programming.

Installation

npm install @write-for-christ/prophet-samuel

How to use?

  const samuel = require('prophet-samuel');

  // Simple usage, only watch on single directory
  samuel().watch('/path/to/watch').subscribe((data) => {
    console.log(data);
  });

  // Recursive mode
  samuel().watch('/path/to/watch', { recursive: true}).subscribe((data) => {
    console.log(data);
  });
  • Notice: Every time we call samuel() a new instance is allocated.
  • If a file changed at /path/to/watch/sub/of/sub/dir/updated.txt the data should be:
   {
      event: 'update',
      path: '/path/to/watch/sub/of/sub/dir/updated.txt',
      dir: '/path/to/watch/sub/of/sub/dir',
      root: '/',
      base: 'updated.txt',
      name: 'updated',
      ext: '.txt',
      rel: '/sub/of/sub/dir/'
   }

About

In the Bible, prophet Samuel always listen for God's Word before doing something, this module will help us listen for files changed and execute actions in reactive way.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages