2023-02-02 08:53:01 -08:00
|
|
|
import {isString} from "@github/actions-workflow-parser";
|
|
|
|
|
import {DefinitionType} from "@github/actions-workflow-parser/templates/schema/definition-type";
|
|
|
|
|
import {StringDefinition} from "@github/actions-workflow-parser/templates/schema/string-definition";
|
|
|
|
|
import {OPEN_EXPRESSION} from "@github/actions-workflow-parser/templates/template-constants";
|
|
|
|
|
import {TemplateToken} from "@github/actions-workflow-parser/templates/tokens/index";
|
|
|
|
|
|
2023-02-02 13:14:02 -08:00
|
|
|
export function isPotentiallyExpression(token: TemplateToken): boolean {
|
|
|
|
|
const isAlwaysExpression =
|
2023-02-02 08:53:01 -08:00
|
|
|
token.definition?.definitionType === DefinitionType.String && (token.definition as StringDefinition).isExpression;
|
2023-02-28 10:18:46 -08:00
|
|
|
const containsExpression = isString(token) && token.value != null && token.value.indexOf(OPEN_EXPRESSION) >= 0;
|
2023-02-02 13:14:02 -08:00
|
|
|
return isAlwaysExpression || containsExpression;
|
2023-02-02 08:53:01 -08:00
|
|
|
}
|