fix(core): update

This commit is contained in:
Philipp Kunz 2019-05-05 20:41:29 +02:00
parent ea26987ca6
commit 0298bfe3c6
9 changed files with 34 additions and 152 deletions

1
dist/index.d.ts vendored
View File

@ -1 +0,0 @@
export * from './smartchok.classes.smartchok';

7
dist/index.js vendored
View File

@ -1,7 +0,0 @@
"use strict";
function __export(m) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./smartchok.classes.smartchok"));
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLG1EQUE4QyJ9

View File

@ -1,39 +0,0 @@
import * as plugins from './smartchok.plugins';
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: plugins.lik.Stringmap;
chokidarOptions: plugins.chokidar.WatchOptions;
status: TSmartchokStatus;
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
*/
add(pathArrayArg: string[]): void;
/**
* removes files from the list of watched files
*/
remove(pathArg: string): void;
/**
* gets an observable for a certain event
*/
getObservableFor(fsEvent: TFsEvent): Promise<plugins.smartrx.rxjs.Observable<any>>;
/**
* starts the watcher
* @returns Promise<void>
*/
start(): Promise<void>;
/**
* stop the watcher process if watching
*/
stop(): void;
}

View File

@ -1,77 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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';
this.watchingDeferred = plugins.smartq.defer(); // used to run things when watcher is initialized
this.eventObservablemap = new plugins.smartrx.Observablemap(); // register one observable per event
this.watchStringmap.addStringArray(watchArrayArg);
this.chokidarOptions = optionsArg;
}
/**
* adds files to the list of watched files
*/
add(pathArrayArg) {
this.watchStringmap.addStringArray(pathArrayArg);
}
/**
* removes files from the list of watched files
*/
remove(pathArg) {
this.watchStringmap.removeString(pathArg);
}
/**
* gets an observable for a certain event
*/
getObservableFor(fsEvent) {
let done = plugins.smartq.defer();
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() {
let done = plugins.smartq.defer();
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();
};
if (this.status === 'watching') {
console.log('closing while watching');
closeWatcher();
}
else if (this.status === 'starting') {
this.watchingDeferred.promise.then(() => {
closeWatcher();
});
}
}
}
exports.Smartchok = Smartchok;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjaG9rLmNsYXNzZXMuc21hcnRjaG9rLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRjaG9rLmNsYXNzZXMuc21hcnRjaG9rLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0NBQStDO0FBQy9DLDZCQUFnQztBQWNoQzs7R0FFRztBQUNIO0lBUUU7O09BRUc7SUFDSCxZQUFZLG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UMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxNQUFNLEtBQUssVUFBVSxDQUFDLENBQUMsQ0FBQztZQUN0QyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxHQUFHLEVBQUU7Z0JBQ3RDLFlBQVksRUFBRSxDQUFDO1lBQ2pCLENBQUMsQ0FBQyxDQUFDO1FBQ0wsQ0FBQztJQUNILENBQUM7Q0FDRjtBQWhGRCw4QkFnRkMifQ==

View File

@ -1,5 +0,0 @@
export import lik = require('lik');
export import chokidar = require('chokidar');
export import path = require('path');
export import smartq = require('smartq');
export import smartrx = require('smartrx');

View File

@ -1,8 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lik = require("lik");
exports.chokidar = require("chokidar");
exports.path = require("path");
exports.smartq = require("smartq");
exports.smartrx = require("smartrx");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRjaG9rLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGNob2sucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZCQUFtQztBQUNuQyx1Q0FBNkM7QUFDN0MsK0JBQXFDO0FBQ3JDLG1DQUF5QztBQUN6QyxxQ0FBMkMifQ==

41
package-lock.json generated
View File

@ -987,7 +987,8 @@
}, },
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true "bundled": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@ -1005,11 +1006,13 @@
}, },
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true "bundled": true,
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@ -1022,15 +1025,18 @@
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true "bundled": true,
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -1133,7 +1139,8 @@
}, },
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true "bundled": true,
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@ -1143,6 +1150,7 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@ -1155,17 +1163,20 @@
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true "bundled": true,
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@ -1182,6 +1193,7 @@
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@ -1254,7 +1266,8 @@
}, },
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true "bundled": true,
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@ -1264,6 +1277,7 @@
"once": { "once": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@ -1339,7 +1353,8 @@
}, },
"safe-buffer": { "safe-buffer": {
"version": "5.1.1", "version": "5.1.1",
"bundled": true "bundled": true,
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@ -1369,6 +1384,7 @@
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
@ -1386,6 +1402,7 @@
"strip-ansi": { "strip-ansi": {
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -1424,11 +1441,13 @@
}, },
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true "bundled": true,
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.2", "version": "3.0.2",
"bundled": true "bundled": true,
"optional": true
} }
} }
}, },

View File

@ -8,7 +8,7 @@
"scripts": { "scripts": {
"test": "(npm run prepareTest && tstest test/)", "test": "(npm run prepareTest && tstest test/)",
"prepareTest": "(rm -f ./test/assets/hi.txt)", "prepareTest": "(rm -f ./test/assets/hi.txt)",
"build": "echo \"Not needed for now\"" "build": "tsbuild"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -2,13 +2,13 @@ import { tap, expect } from '@pushrocks/tapbundle';
import * as smartchok from '../ts/index'; import * as smartchok from '../ts/index';
import * as smartfile from '@pushrocks/smartfile'; import * as smartfile from '@pushrocks/smartfile';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as rx from 'rxjs/Rx'; import * as smartrx from '@pushrocks/smartrx';
// the module to test // the module to test
let testSmartchok: smartchok.Smartchok; let testSmartchok: smartchok.Smartchok;
let testAddObservable: rx.Observable<any>; let testAddObservable: smartrx.rxjs.Observable<any>;
let testSubscription: rx.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([]);
expect(testSmartchok).to.be.instanceof(smartchok.Smartchok); expect(testSmartchok).to.be.instanceof(smartchok.Smartchok);