add crontab tests
This commit is contained in:
+2
-2
@@ -275,7 +275,7 @@ function parseCrontab(crontab) {
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i].trim();
|
||||
if (!line || line.startsWith('#')) continue;
|
||||
const parts = /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*)/.exec(line);
|
||||
const parts = /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$/.exec(line);
|
||||
if (!parts) throw new BoxError(BoxError.BAD_FIELD, `Invalid cron configuration at line ${i+1}`);
|
||||
const schedule = parts.slice(1, 6).join(' ');
|
||||
const command = parts[6];
|
||||
@@ -286,7 +286,7 @@ function parseCrontab(crontab) {
|
||||
throw new BoxError(BoxError.BAD_FIELD, `Invalid cron pattern at line ${i+1}`);
|
||||
}
|
||||
|
||||
if (command.length === 0) throw new BoxError(BoxError.BAD_FIELD, `Invalid cron pattern. Command must not be empty at line ${i+1}`);
|
||||
if (command.length === 0) throw new BoxError(BoxError.BAD_FIELD, `Invalid cron pattern. Command must not be empty at line ${i+1}`); // not possible with the regexp we have
|
||||
|
||||
result.push({ schedule, command });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user