-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (32 loc) · 1009 Bytes
/
index.js
File metadata and controls
38 lines (32 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const chokidar = require('chokidar');
const Trigger = require('@runnerty/module-core').Trigger;
class triggerFileWatcher extends Trigger {
constructor(chain, params) {
super(chain, params);
}
start() {
// Create file watcher:
this.fileWatcher = chokidar.watch(this.params.file_name, {
ignored: /(^|[\/\\])\../,
persistent: true,
usePolling: true,
ignoreInitial: true,
awaitWriteFinish: {
stabilityThreshold: 2000,
pollInterval: 150
}
});
// Create watch condition:
this.fileWatcher.on(this.params.condition, pathfile => {
const checkCalendar = true;
const inputValues = [];
const customValues = { file_name: pathfile };
// Start Chain: Send file_name into inputValues.
this.startChain(checkCalendar, inputValues, customValues).catch(err => {
this.logger.error('startChain error (triggerFileWatcher):', err);
});
});
}
}
module.exports = triggerFileWatcher;