update dependencies

This commit is contained in:
Philipp Kunz 2017-02-15 21:58:34 +01:00
parent c6104ed00e
commit 722bd0ea61
6 changed files with 1362 additions and 85 deletions

View File

@ -2,14 +2,15 @@
smart wrapper for chokidar
## Availabililty
[![npm](https://push.rocks/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartchok)
[![git](https://push.rocks/assets/repo-button-git.svg)](https://gitlab.com/pushrocks/smartchok)
[![git](https://push.rocks/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartchok)
[![docs](https://push.rocks/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartchok/)
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartchok)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartchok)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartchok)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartchok/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartchok/badges/master/build.svg)](https://gitlab.com/pushrocks/smartchok/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartchok/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartchok/commits/master)
[![build status](https://GitLab.com/pushrocks/smartchok/badges/master/build.svg)](https://GitLab.com/pushrocks/smartchok/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartchok/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartchok/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartchok.svg)](https://www.npmjs.com/package/smartchok)
[![Dependency Status](https://david-dm.org/pushrocks/smartchok.svg)](https://david-dm.org/pushrocks/smartchok)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartchok/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartchok/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartchok/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartchok)
@ -18,7 +19,7 @@ smart wrapper for chokidar
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
We recommend the use of TypeScript for best in class Intellisense
Use TypeScript for best in class instellisense.
```javascript
import { Smartchok } from 'smartchok'
@ -43,4 +44,8 @@ mySmartChok.getObservableFor('change').then((observableArg) => {
mySmartChok.stop()
```
[![npm](https://push.rocks/assets/repo-header.svg)](https://push.rocks)
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

6
dist/index.d.ts vendored
View File

@ -4,6 +4,9 @@ import * as plugins from './smartchok.plugins';
import { Stringmap } from 'lik';
export declare type TSmartchokStatus = 'idle' | 'starting' | 'watching';
export declare type TFsEvent = 'add' | 'addDir' | 'change' | 'error' | 'unlink' | 'unlinkDir' | 'ready' | 'raw';
/**
* Smartchok allows easy wathcing of files
*/
export declare class Smartchok {
watchStringmap: Stringmap;
chokidarOptions: plugins.chokidar.WatchOptions;
@ -11,6 +14,9 @@ export declare class Smartchok {
private watcher;
private watchingDeferred;
private eventObservablemap;
/**
* constructor of class smartchok
*/
constructor(watchArrayArg: string[], optionsArg?: plugins.chokidar.WatchOptions);
/**
* adds files to the list of watched files

8
dist/index.js vendored
View File

@ -1,7 +1,13 @@
"use strict";
const plugins = require("./smartchok.plugins");
const lik_1 = require("lik");
/**
* Smartchok allows easy wathcing of files
*/
class Smartchok {
/**
* constructor of class smartchok
*/
constructor(watchArrayArg, optionsArg = {}) {
this.watchStringmap = new lik_1.Stringmap();
this.status = 'idle';
@ -73,4 +79,4 @@ class Smartchok {
}
}
exports.Smartchok = Smartchok;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC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OztPQUVHO0lBQ0gsSUFBSTtRQUNGLElBQUksWUFBWSxHQUFHO1lBQ2pCLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDdEIsQ0FBQyxDQUFBO1FBQ0QsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLE1BQU0sS0FBSyxVQUFVLENBQUMsQ0FBQyxDQUFDO1lBQy9CLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQTtZQUNyQyxZQUFZLEVBQUUsQ0FBQTtRQUNoQixDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxNQUFNLEtBQUssVUFBVSxDQUFDLENBQUMsQ0FBQztZQUN0QyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxRQUFRLFlBQVksRUFBRSxDQUFBLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDOUQsQ0FBQztJQUNILENBQUM7Q0FDRjtBQWpGRCw4QkFpRkMifQ==

View File

@ -19,18 +19,18 @@
},
"homepage": "https://gitlab.com/pushrocks/smartchok#README",
"dependencies": {
"@types/chokidar": "^1.4.29",
"@types/chokidar": "^1.4.31",
"@types/q": "x.x.x",
"chokidar": "^1.6.1",
"lik": "^1.0.24",
"lik": "^1.0.27",
"q": "^1.4.1",
"rxjs": "^5.0.0-rc.3",
"rxjs": "^5.1.1",
"typings-global": "^1.0.14"
},
"devDependencies": {
"@types/should": "^8.1.30",
"should": "^11.1.1",
"smartfile": "^4.1.0",
"should": "^11.2.0",
"smartfile": "^4.1.5",
"typings-test": "^1.0.3"
}
}

View File

@ -8,84 +8,84 @@ export type TFsEvent = 'add' | 'addDir' | 'change' | 'error' | 'unlink' | 'unlin
* Smartchok allows easy wathcing of files
*/
export class Smartchok {
watchStringmap = new Stringmap()
chokidarOptions: plugins.chokidar.WatchOptions
status: TSmartchokStatus = 'idle'
private watcher
private watchingDeferred = plugins.q.defer<void>() // used to run things when watcher is initialized
private eventObservablemap = new plugins.lik.Observablemap() // register one observable per event
watchStringmap = new Stringmap()
chokidarOptions: plugins.chokidar.WatchOptions
status: TSmartchokStatus = 'idle'
private watcher
private watchingDeferred = plugins.q.defer<void>() // used to run things when watcher is initialized
private eventObservablemap = new plugins.lik.Observablemap() // register one observable per event
/**
* constructor of class smartchok
*/
constructor(watchArrayArg: string[], optionsArg: plugins.chokidar.WatchOptions = {}) {
this.watchStringmap.addStringArray(watchArrayArg)
this.chokidarOptions = optionsArg
/**
* constructor of class smartchok
*/
constructor(watchArrayArg: string[], optionsArg: plugins.chokidar.WatchOptions = {}) {
this.watchStringmap.addStringArray(watchArrayArg)
this.chokidarOptions = optionsArg
}
/**
* adds files to the list of watched files
*/
add(pathArrayArg: string[]) {
this.watchStringmap.addStringArray(pathArrayArg)
if (this.status !== 'idle') {
this.watchingDeferred.promise.then(() => {
this.watcher.add(pathArrayArg)
})
}
/**
* adds files to the list of watched files
*/
add(pathArrayArg: string[]) {
this.watchStringmap.addStringArray(pathArrayArg)
if (this.status !== 'idle') {
this.watchingDeferred.promise.then(() => {
this.watcher.add(pathArrayArg)
})
}
}
}
/**
* removes files from the list of watched files
*/
remove(pathArg: string) {
this.watchStringmap.removeString('') // TODO
this.watchingDeferred.promise.then(() => {
this.watcher.unwatch(pathArg)
})
}
/**
* removes files from the list of watched files
*/
remove(pathArg: string) {
this.watchStringmap.removeString('') // TODO
this.watchingDeferred.promise.then(() => {
this.watcher.unwatch(pathArg)
})
}
/**
* gets an observable for a certain event
*/
getObservableFor(fsEvent: TFsEvent): plugins.q.Promise<plugins.rx.Observable<any>> {
let done = plugins.q.defer<plugins.rx.Observable<any>>()
this.watchingDeferred.promise.then(() => {
let eventObservable = this.eventObservablemap.getObservableForEmitterEvent(this.watcher, fsEvent)
done.resolve(eventObservable)
})
return done.promise
}
/**
* gets an observable for a certain event
*/
getObservableFor(fsEvent: TFsEvent): plugins.q.Promise<plugins.rx.Observable<any>> {
let done = plugins.q.defer<plugins.rx.Observable<any>>()
this.watchingDeferred.promise.then(() => {
let eventObservable = this.eventObservablemap.getObservableForEmitterEvent(this.watcher, fsEvent)
done.resolve(eventObservable)
})
return done.promise
}
/**
* starts the watcher
* @returns Promise<void>
*/
start(): plugins.q.Promise<void> {
let done = plugins.q.defer<void>()
this.status = 'starting'
this.watcher = plugins.chokidar.watch(this.watchStringmap.getStringArray(), this.chokidarOptions)
this.watcher.on('ready', () => {
this.status = 'watching'
this.watchingDeferred.resolve()
done.resolve()
})
return done.promise
}
/**
* starts the watcher
* @returns Promise<void>
*/
start(): plugins.q.Promise<void> {
let done = plugins.q.defer<void>()
this.status = 'starting'
this.watcher = plugins.chokidar.watch(this.watchStringmap.getStringArray(), this.chokidarOptions)
this.watcher.on('ready', () => {
this.status = 'watching'
this.watchingDeferred.resolve()
done.resolve()
})
return done.promise
/**
* stop the watcher process if watching
*/
stop() {
let closeWatcher = () => {
this.watcher.close()
}
/**
* stop the watcher process if watching
*/
stop() {
let closeWatcher = () => {
this.watcher.close()
}
if (this.status === 'watching') {
console.log('closing while watching')
closeWatcher()
} else if (this.status === 'starting') {
this.watchingDeferred.promise.then(() => { closeWatcher() })
}
if (this.status === 'watching') {
console.log('closing while watching')
closeWatcher()
} else if (this.status === 'starting') {
this.watchingDeferred.promise.then(() => { closeWatcher() })
}
}
}

1260
yarn.lock Normal file

File diff suppressed because it is too large Load Diff