fix process not exiting problem
This commit is contained in:
parent
276494c8a2
commit
0fe26b4b44
19
dist/index.js
vendored
19
dist/index.js
vendored
@ -4,6 +4,7 @@ const lik_1 = require("lik");
|
||||
class Smartchok {
|
||||
constructor(watchArrayArg, optionsArg = {}) {
|
||||
this.watchStringmap = new lik_1.Stringmap();
|
||||
this.status = 'idle';
|
||||
this.watchingDeferred = plugins.q.defer(); // used to run things when watcher is initialized
|
||||
this.eventObservablemap = new plugins.lik.Observablemap(); // register one observable per event
|
||||
this.watchStringmap.addStringArray(watchArrayArg);
|
||||
@ -14,9 +15,11 @@ class Smartchok {
|
||||
*/
|
||||
add(pathArrayArg) {
|
||||
this.watchStringmap.addStringArray(pathArrayArg);
|
||||
this.watchingDeferred.promise.then(() => {
|
||||
this.watcher.add(pathArrayArg);
|
||||
});
|
||||
if (this.status !== 'idle') {
|
||||
this.watchingDeferred.promise.then(() => {
|
||||
this.watcher.add(pathArrayArg);
|
||||
});
|
||||
}
|
||||
}
|
||||
/**
|
||||
* removes files from the list of watched files
|
||||
@ -58,14 +61,6 @@ class Smartchok {
|
||||
*/
|
||||
stop() {
|
||||
let closeWatcher = () => {
|
||||
let watchedFiles = this.watcher.getWatched();
|
||||
for (let key in watchedFiles) {
|
||||
let files = watchedFiles[key];
|
||||
for (let file in files) {
|
||||
let filePath = plugins.path.join(key, file);
|
||||
this.watcher.unwatch(filePath);
|
||||
}
|
||||
}
|
||||
this.watcher.close();
|
||||
};
|
||||
if (this.status === 'watching') {
|
||||
@ -78,4 +73,4 @@ class Smartchok {
|
||||
}
|
||||
}
|
||||
exports.Smartchok = Smartchok;
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQThDO0FBQzlDLDZCQUErQjtBQUsvQjtJQVFJLF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SSxDQUFDLE1BQU0sR0FBRyxVQUFVLENBQUE7WUFDeEIsSUFBSSxDQUFDLGdCQUFnQixDQUFDLE9BQU8sRUFBRSxDQUFBO1lBQy9CLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtRQUNsQixDQUFDLENBQUMsQ0FBQTtRQUNGLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0lBQ3ZCLENBQUM7SUFFRDs7T0FFRztJQUNILElBQUk7UUFDQSxJQUFJLFlBQVksR0FBRztZQUNmLElBQUksQ0FBQyxPQUFPLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDeEIsQ0FBQyxDQUFBO1FBQ0QsRUFBRSxDQUFDLENBQUMsSUFBSSxDQUFDLE1BQU0sS0FBSyxVQUFVLENBQUMsQ0FBQyxDQUFDO1lBQzdCLE9BQU8sQ0FBQyxHQUFHLENBQUMsd0JBQXdCLENBQUMsQ0FBQTtZQUNyQyxZQUFZLEVBQUUsQ0FBQTtRQUNsQixDQUFDO1FBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxDQUFDLElBQUksQ0FBQyxNQUFNLEtBQUssVUFBVSxDQUFDLENBQUMsQ0FBQztZQUNwQyxJQUFJLENBQUMsZ0JBQWdCLENBQUMsT0FBTyxDQUFDLElBQUksQ0FBQyxRQUFRLFlBQVksRUFBRSxDQUFBLENBQUMsQ0FBQyxDQUFDLENBQUE7UUFDaEUsQ0FBQztJQUNMLENBQUM7Q0FDSjtBQTlFRCw4QkE4RUMifQ==
|
11
ts/index.ts
11
ts/index.ts
@ -7,7 +7,7 @@ export type TFsEvent = 'add' | 'addDir' | 'change' | 'error' | 'unlink' | 'unlin
|
||||
export class Smartchok {
|
||||
watchStringmap = new Stringmap()
|
||||
chokidarOptions: plugins.chokidar.WatchOptions
|
||||
status: TSmartchokStatus
|
||||
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
|
||||
@ -22,9 +22,12 @@ export class Smartchok {
|
||||
*/
|
||||
add(pathArrayArg: string[]) {
|
||||
this.watchStringmap.addStringArray(pathArrayArg)
|
||||
this.watchingDeferred.promise.then(() => {
|
||||
this.watcher.add(pathArrayArg)
|
||||
})
|
||||
if (this.status !== 'idle') {
|
||||
this.watchingDeferred.promise.then(() => {
|
||||
this.watcher.add(pathArrayArg)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user