Address feedback

This commit is contained in:
Jacob Wallraff
2023-01-23 17:50:54 -08:00
parent af5c15a422
commit 58d92658b6
5 changed files with 19 additions and 23 deletions
+2 -2
View File
@@ -110,7 +110,7 @@ jobs:
);
});
it("on a cron identifier", async () => {
it("on a cron mapping key", async () => {
const input = `on:
schedule:
- c|ron: '0 0 * * *'
@@ -127,7 +127,7 @@ jobs:
`;
const result = await hover(...getPositionFromCursor(input));
expect(result).not.toBeUndefined();
expect(result?.contents).toEqual("Invalid cron expression");
expect(result?.contents).toEqual("");
});
});
+5 -12
View File
@@ -12,7 +12,7 @@ import {info} from "./log";
import {nullTrace} from "./nulltrace";
import {findToken} from "./utils/find-token";
import {mapRange} from "./utils/range";
import {getSentence} from "@github/actions-workflow-parser/model/converter/cron";
import {getCronDescription} from "@github/actions-workflow-parser/model/converter/cron";
export type DescriptionProvider = {
getDescription(context: WorkflowContext, token: TemplateToken, path: TemplateToken[]): Promise<string | undefined>;
@@ -40,20 +40,13 @@ export async function hover(document: TextDocument, position: Position, config?:
if (tokenResult.parent && isCronMappingValue(tokenResult)) {
const tokenValue = (token as StringToken).value
let description = getSentence(tokenValue);
let description = getCronDescription(tokenValue);
if (description) {
description +=
"\n\nActions schedules run at most every 5 minutes." +
" [Learn more](https://docs.github.com/actions/using-workflows/workflow-syntax-for-github-actions#onschedule)";
return {
contents: description,
range: mapRange(token.range)
} as Hover;
}
return {
contents: "Invalid cron expression",
range: mapRange(token.range)
} as Hover;
}
let description = await getDescription(document, config, result, token, tokenResult.path);
@@ -90,7 +83,7 @@ async function getDescription(
}
function isCronMappingValue(tokenResult: TokenResult): boolean {
return tokenResult.parent?.definition?.key === "cron-mapping" &&
(tokenResult.token as StringToken).value !== "cron" &&
isString(tokenResult.token!);
//return tokenResult.parent?.definition?.key === "cron-mapping" &&
return isString(tokenResult.token!) &&
(tokenResult.token as StringToken).value !== "cron"
}