1.0.0 • Published 2 years ago

@xdoer/chokidar v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Chokidar

This is based on paulmillr' chokidar project which make it easier to use.

Install

yarn add @xdoer/chokidar

Example

import chokidar from '@xdoer/chokidar'

chokidar({
  options: { persistent: true, ignoreInitial: true },
  list: [
    {
      target: '../dist/*',
      options: { ignoreInitial: false },
      watch: {
        add(watcher, path) {
          // do something
        },
        change(watcher, path) {
          // do something
        },
        // ...
      },
    },
    {
      target: ['**/src/demo/**', '**/src/api/**'],
      options: { ignoreInitial: false },
      watch: {
        add(watcher, path) {
          // do something
        },
        change(watcher, path) {
          // do something
        },
        // ...
      },
    },
  ],
})

Options

Main Options

OptionTypeMappingMeaning
optionsWatchOptionschokidar.watch(target, options)main watch options
listChokidarOption[]watch list

ChokidarOption

OptionTypeMappingMeaning
targetstring | string[]chokidar.watch(target, options)The file or dir you want to watch
optionsWatchOptionschokidar.watch(target, options)watch options
watchChokidarWatchEventchokidar.watch().onwatch().on callback

ChokidarWatchEvent

OptionTypeMapping
ready(watcher: FSWatcher) => voidchokidar.watch().on('ready', callback)
add(watcher: FSWatcher, path: string, status?: Stats) => voidchokidar.watch().on('add', callback)
addDir(watcher: FSWatcher, path: string, status?: Stats) => voidchokidar.watch().on('addDir', callback)
change(watcher: FSWatcher, path: string, status?: Stats) => voidchokidar.watch().on('change', callback)
unlink(watcher: FSWatcher, path: string, status?: Stats) => voidchokidar.watch().on('unlink', callback)
unlinkDir(watcher: FSWatcher, path: string, status?: Stats) => voidchokidar.watch().on('unlinkDir', callback)
raw(watcher: FSWatcher, eventName: string, path: string, details: any) => voidchokidar.watch().on('raw', callback)
all(watcher: FSWatcher, eventName: EventName, path: string, status?: Stats) => voidchokidar.watch().on('all', callback)
error(watcher: FSWatcher, e: Error) => voidchokidar.watch().on('error', callback)
1.0.0

2 years ago

0.0.2

3 years ago

0.0.1

3 years ago