How to use the cron-parser.parseString function in cron-parser

To help you get started, we’ve selected a few cron-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github alseambusher / crontab-ui / crontab.js View on Github external
lines.forEach(function(line, index){
			line = line.replace(/\t+/g, ' ');
			var regex = /^((\@[a-zA-Z]+\s+)|(([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+))/;
			var command = line.replace(regex, '').trim();
			var schedule = line.replace(command, '').trim();

			var is_valid = false;
			try { is_valid = cron_parser.parseString(line).expressions.length > 0; } catch (e){}

			if(command && schedule && is_valid){
				var name = namePrefix + '_' + index;

				db.findOne({ command: command, schedule: schedule }, function(err, doc) {
					if(err) {
						throw err;
					}
					if(!doc){
						exports.create_new(name, command, schedule, null);
					}
					else{
						doc.command = command;
						doc.schedule = schedule;
						exports.update(doc);
					}
github Qihoo360 / wayne / src / frontend / src / app / portal / cronjob / create-edit-cronjobtpl / create-edit-cronjobtpl.component.ts View on Github external
get isScheduleValid(): boolean {
    if (!this.kubeResource.spec.schedule) {
      return false;
    }
    const result = cron.parseString(this.kubeResource.spec.schedule);
    if (Object.keys(result.errors).length !== 0) {
      return false;
    }
    return true;
  }

cron-parser

Node.js library for parsing crontab instructions

MIT
Latest version published 9 months ago

Package Health Score

77 / 100
Full package analysis