Add tests and small bug fixes
This commit is contained in:
@@ -43,7 +43,6 @@ describe("cron", () => {
|
||||
["0 */* * * *", "step start and size may not both be *"],
|
||||
["0 5/* * * *", "steps size may not be *"],
|
||||
["0 *-4 5-* *-* *", "range may not contain *"],
|
||||
["0 *//5 * * *", "should not accept multiple /"],
|
||||
["0 ,, * * *", "should not accept multiple ,"],
|
||||
[", , , , ,", "comma is not a valid part"],
|
||||
["0 ** * * *", "should not accept multiple *"],
|
||||
|
||||
@@ -60,7 +60,8 @@ export function getSentence(cronspec: string): string | undefined {
|
||||
return
|
||||
}
|
||||
|
||||
return desc
|
||||
// Make first character lowercase
|
||||
return "Runs " + desc.charAt(0).toLowerCase() + desc.slice(1)
|
||||
}
|
||||
|
||||
function parseCronPart(part: string, range: Range): number[] | undefined {
|
||||
|
||||
@@ -229,9 +229,14 @@ class TemplateReader {
|
||||
else if (upperKey === "CRON") {
|
||||
// Schedules are a special case, we have to calculate the description
|
||||
if (isString(nextValue)) {
|
||||
nextValue.description = getSentence((nextValue as StringToken).value)
|
||||
nextValue.description += "\nActions schedules run at most every 5 minutes." +
|
||||
" [Learn more](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#onschedule)";
|
||||
const cronDescription = getSentence((nextValue as StringToken).value)
|
||||
if (cronDescription) {
|
||||
nextValue.description = cronDescription + "\n\nActions schedules run at most every 5 minutes." +
|
||||
" [Learn more](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#onschedule)";
|
||||
}
|
||||
else {
|
||||
nextValue.description = "Invalid cron expression"
|
||||
}
|
||||
}
|
||||
else {
|
||||
nextValue.description = "Cron expression must be a string"
|
||||
|
||||
Reference in New Issue
Block a user