A cron helper that imports a given folder
$ npm install -g cron-module-actions
Modules are javascript files that export name
, description
, schedule
, author
and action
properties.
All should be strings, except action
that should be a void
function.
schedule
prop must be a valid cron time format.
export const name = "Name";
export const description = "Description";
export const schedule = "1 * * * * *";
export const author = "[email protected]"
export function action() {
console.log(`Hello!`, new Date());
}
$ cma ./path/to/folder/with/modules
cronModuleActions(
/* only .js modules will be imported */
await getModules(`file/to/modules`),
/* muted, if false will console.log information */
true
)