Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
7c4324b3ad | |||
268201727c | |||
12ae27b2ff | |||
3bb9b2229d | |||
e17e4c376e | |||
d5f2427aad |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartchok",
|
"name": "@pushrocks/smartchok",
|
||||||
"version": "1.0.24",
|
"version": "1.0.27",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smartchok",
|
"name": "@pushrocks/smartchok",
|
||||||
"version": "1.0.24",
|
"version": "1.0.27",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^5.0.0",
|
"@pushrocks/lik": "^5.0.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartchok",
|
"name": "@pushrocks/smartchok",
|
||||||
"version": "1.0.24",
|
"version": "1.0.27",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "smart wrapper for chokidar",
|
"description": "smart wrapper for chokidar",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -24,7 +24,6 @@
|
|||||||
"@pushrocks/lik": "^5.0.0",
|
"@pushrocks/lik": "^5.0.0",
|
||||||
"@pushrocks/smartpromise": "^3.1.6",
|
"@pushrocks/smartpromise": "^3.1.6",
|
||||||
"@pushrocks/smartrx": "^2.0.19",
|
"@pushrocks/smartrx": "^2.0.19",
|
||||||
"@types/chokidar": "^2.1.3",
|
|
||||||
"chokidar": "^3.5.2"
|
"chokidar": "^3.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
63
readme.md
Normal file
63
readme.md
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# @pushrocks/smartchok
|
||||||
|
smart wrapper for chokidar
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartchokidar)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartchok)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartchok)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartchok/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
|
||||||
|
Status Category | Status Badge
|
||||||
|
-- | --
|
||||||
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
|
npm | [](https://lossless.cloud)
|
||||||
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import { Smartchok } from 'smartchok';
|
||||||
|
|
||||||
|
const mySmartChok = new Smartchok(['some/path/**/*.any', '/absolute/*.js'], chokidarOptions);
|
||||||
|
|
||||||
|
mySmartChok.add(['/some/**/*.any']); // add files
|
||||||
|
|
||||||
|
mySmartChok.remove('some/**/*.js');
|
||||||
|
|
||||||
|
mySmartChok.start(); // starts the watch process
|
||||||
|
|
||||||
|
mySmartChok.getObservableFor('change').then((observableArg) => {
|
||||||
|
observableArg.subscribe((x) => {
|
||||||
|
// do something here when a change is detected
|
||||||
|
// possible events are 'add' | 'addDir' | 'change' | 'error' | 'unlink' | 'unlinkDir' | 'ready' | 'raw'
|
||||||
|
// note that the observable is only created once you call .start() on the Smartchok instance
|
||||||
|
// hence the promise construction
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
mySmartChok.stop();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Contribution
|
||||||
|
|
||||||
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
@ -4,13 +4,15 @@ import * as smartfile from '@pushrocks/smartfile';
|
|||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
import * as smartrx from '@pushrocks/smartrx';
|
import * as smartrx from '@pushrocks/smartrx';
|
||||||
|
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
// the module to test
|
// the module to test
|
||||||
if (process.env.CI) {
|
if (process.env.CI) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
let testSmartchok: smartchok.Smartchok;
|
let testSmartchok: smartchok.Smartchok;
|
||||||
let testAddObservable: smartrx.rxjs.Observable<any>;
|
let testAddObservable: smartrx.rxjs.Observable<[string, fs.Stats]>;
|
||||||
let testSubscription: smartrx.rxjs.Subscription;
|
let testSubscription: smartrx.rxjs.Subscription;
|
||||||
tap.test('should create a new instance', async () => {
|
tap.test('should create a new instance', async () => {
|
||||||
testSmartchok = new smartchok.Smartchok([]);
|
testSmartchok = new smartchok.Smartchok([]);
|
||||||
@ -31,7 +33,9 @@ tap.test('should get an observable for a certain event', async () => {
|
|||||||
|
|
||||||
tap.test('should register an add operation', async () => {
|
tap.test('should register an add operation', async () => {
|
||||||
let testDeferred = smartpromise.defer();
|
let testDeferred = smartpromise.defer();
|
||||||
testSubscription = testAddObservable.subscribe((x) => {
|
testSubscription = testAddObservable.subscribe(pathArg => {
|
||||||
|
const pathResult = pathArg[0];
|
||||||
|
console.log(pathResult);
|
||||||
testDeferred.resolve();
|
testDeferred.resolve();
|
||||||
});
|
});
|
||||||
smartfile.memory.toFs('HI', './test/assets/hi.txt');
|
smartfile.memory.toFs('HI', './test/assets/hi.txt');
|
||||||
|
@ -49,7 +49,7 @@ export class Smartchok {
|
|||||||
/**
|
/**
|
||||||
* gets an observable for a certain event
|
* gets an observable for a certain event
|
||||||
*/
|
*/
|
||||||
public getObservableFor(fsEvent: TFsEvent): Promise<plugins.smartrx.rxjs.Observable<any>> {
|
public getObservableFor(fsEvent: TFsEvent): Promise<plugins.smartrx.rxjs.Observable<[string, plugins.fs.Stats]>> {
|
||||||
const 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(() => {
|
||||||
const eventObservable = this.eventObservablemap.getObservableForEmitterEvent(
|
const eventObservable = this.eventObservablemap.getObservableForEmitterEvent(
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// node native
|
// node native
|
||||||
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
fs,
|
||||||
path
|
path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user