Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Use chokidar instead of fs for watching files. #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"dependencies": {
"@paulcbetts/mime-types": "^2.1.10",
"btoa": "^1.1.2",
"chokidar": "^1.6.1",
"debug": "^2.5.1",
"lru-cache": "^4.0.1",
"mkdirp": "^0.5.1",
Expand Down
9 changes: 6 additions & 3 deletions src/pathwatcher-rx.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import fs from 'fs';
import {Observable} from 'rxjs/Observable';
import {Subscription} from 'rxjs/Subscription';
import LRU from 'lru-cache';
import chokidar from 'chokidar';

import 'rxjs/add/operator/publish';

export function watchPathDirect(directory) {
return Observable.create((subj) => {
let dead = false;

const watcher = fs.watch(directory, {}, (eventType, fileName) => {
const watcher = chokidar.watch(directory)

watcher.on('change', (fileName) => {
if (dead) return;
subj.next({eventType, fileName});

subj.next({fileName});
});

watcher.on('error', (e) => {
Expand Down