1.1.1 • Published 6 years ago
hot-folder-manager v1.1.1
A simple interface for managing watch folders for processing files and folders.
Installation
npm install hot-folder-manager
version 1.1.0
Changed dependency from node-watch to chokidar to avoid events triggering multiple times while a file was being written.
Event names have changed!
node-watch events
chokidar events
Example
const hotFolders = require('hot-folder-manager');
// just to emulate assigning a logger
const logger = console;
const options = {
tasks: [
{
name: 'log_entries',
folders: {
in: '/'
},
processFn: (options, event, name) => {
const value = options.extras.someValue;
options.logger.info(`${event}: ${name} - someValue = ${value}`);
},
extensions: ['*'],
logger,
onError: (err) => {logger.error(err);},
verbose: true,
recursive: true,
extras: {
someValue: 'example'
}
}
],
}
hotFolders.create(options)
.then((manager) => {
return manager.start()
.then(manager.stop)
.then(manager.info)
.then(logger.info)
.then(() => {
return manager.start('log_entries');
})
})
.catch(logger.error)
Required Options
tasks: Array
The task objects in the tasks array require:
folders: Object
(must have an 'in' property)processFn: Function
extensions: Array