fix(core): update

This commit is contained in:
Philipp Kunz 2019-09-29 16:35:12 +02:00
parent 771c454411
commit 90ae869686
3 changed files with 335 additions and 473 deletions

764
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -21,20 +21,20 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartchok#README", "homepage": "https://gitlab.com/pushrocks/smartchok#README",
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.5", "@pushrocks/lik": "^3.0.11",
"@pushrocks/smartpromise": "^3.0.2", "@pushrocks/smartpromise": "^3.0.5",
"@pushrocks/smartrx": "^2.0.3", "@pushrocks/smartrx": "^2.0.5",
"@types/chokidar": "^2.1.3", "@types/chokidar": "^2.1.3",
"chokidar": "^3.0.1" "chokidar": "^3.1.1"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.11", "@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.6", "@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.24", "@gitzone/tstest": "^1.0.24",
"@pushrocks/smartfile": "^7.0.2", "@pushrocks/smartfile": "^7.0.5",
"@pushrocks/tapbundle": "^3.0.9", "@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.0.4", "@types/node": "^12.7.8",
"tslint": "^5.17.0", "tslint": "^5.20.0",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [

View File

@ -17,9 +17,9 @@ export type TFsEvent =
* Smartchok allows easy wathcing of files * Smartchok allows easy wathcing of files
*/ */
export class Smartchok { export class Smartchok {
watchStringmap = new Stringmap(); public watchStringmap = new Stringmap();
chokidarOptions: plugins.chokidar.WatchOptions; public chokidarOptions: plugins.chokidar.WatchOptions;
status: TSmartchokStatus = 'idle'; public status: TSmartchokStatus = 'idle';
private watcher: plugins.chokidar.FSWatcher; private watcher: plugins.chokidar.FSWatcher;
private watchingDeferred = plugins.smartpromise.defer<void>(); // used to run things when watcher is initialized private watchingDeferred = plugins.smartpromise.defer<void>(); // used to run things when watcher is initialized
private eventObservablemap = new plugins.smartrx.Observablemap(); // register one observable per event private eventObservablemap = new plugins.smartrx.Observablemap(); // register one observable per event
@ -35,24 +35,24 @@ export class Smartchok {
/** /**
* adds files to the list of watched files * adds files to the list of watched files
*/ */
add(pathArrayArg: string[]) { public add(pathArrayArg: string[]) {
this.watchStringmap.addStringArray(pathArrayArg); this.watchStringmap.addStringArray(pathArrayArg);
} }
/** /**
* removes files from the list of watched files * removes files from the list of watched files
*/ */
remove(pathArg: string) { public remove(pathArg: string) {
this.watchStringmap.removeString(pathArg); this.watchStringmap.removeString(pathArg);
} }
/** /**
* gets an observable for a certain event * gets an observable for a certain event
*/ */
getObservableFor(fsEvent: TFsEvent): Promise<plugins.smartrx.rxjs.Observable<any>> { public getObservableFor(fsEvent: TFsEvent): Promise<plugins.smartrx.rxjs.Observable<any>> {
let done = plugins.smartpromise.defer<plugins.smartrx.rxjs.Observable<any>>(); const done = plugins.smartpromise.defer<plugins.smartrx.rxjs.Observable<any>>();
this.watchingDeferred.promise.then(() => { this.watchingDeferred.promise.then(() => {
let eventObservable = this.eventObservablemap.getObservableForEmitterEvent( const eventObservable = this.eventObservablemap.getObservableForEmitterEvent(
this.watcher, this.watcher,
fsEvent fsEvent
); );
@ -65,8 +65,8 @@ export class Smartchok {
* starts the watcher * starts the watcher
* @returns Promise<void> * @returns Promise<void>
*/ */
start(): Promise<void> { public start(): Promise<void> {
let done = plugins.smartpromise.defer<void>(); const done = plugins.smartpromise.defer<void>();
this.status = 'starting'; this.status = 'starting';
this.watcher = plugins.chokidar.watch( this.watcher = plugins.chokidar.watch(
this.watchStringmap.getStringArray(), this.watchStringmap.getStringArray(),
@ -83,8 +83,8 @@ export class Smartchok {
/** /**
* stop the watcher process if watching * stop the watcher process if watching
*/ */
stop() { public stop() {
let closeWatcher = () => { const closeWatcher = () => {
this.watcher.close(); this.watcher.close();
}; };
if (this.status === 'watching') { if (this.status === 'watching') {