/**
 * Copyright 2018 Twitter, Inc.
 * Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0
 */ import { Filesystem , LocalFilesystem } from "sqrl" ; import * as chokidar from "chokidar" ; import { join } from "path" ; export class WatchedFilesystem extends Filesystem { private watcher : chokidar . FSWatcher ; private fs : LocalFilesystem ; constructor ( private pwd ) { super ( ) ; this . fs = new LocalFilesystem ( pwd ) ; this . watcher = chokidar . watch ( [ ] , { ignoreInitial : true , persistent : false , usePolling : true , } ) ; } on ( event , callback ) { this . watcher . on ( "all" , callback ) ; } private watch ( path ) { this . watcher . add ( join ( this . pwd , path ) ) ; } tryList ( path ) { this . watch ( path ) ; return this . fs . tryList ( path ) ; } tryRead ( path ) { this . watch ( path ) ; return this . fs . tryRead ( path ) ; } }