atomist / automation-client

Automation client for running command and events handlers against the Atomist API.
GNU General Public License v3.0
15 stars 16 forks source link

make evaluateExpression return falsey on not match #166

Closed jessitron closed 4 years ago

jessitron commented 6 years ago

here: https://github.com/atomist/automation-client-ts/blob/4e7a76592bb5a55d4c87fe74a9f3a292d3551bfa/src/tree/ast/FileHits.ts#L46

this returns any, which is sad. It actually returns an array of match results which is empty for no matches

We wanted to write evaluateExpression(findExportKeyword) ? "public" : "private"

so we would like evaluateAny to return MatchResult[] | null and be falsey without matches.

timothysparg commented 4 years ago

@jessitron I see that the signature is now evaluateExpression(pex: string | PathExpression): ExecutionResult;

ExecutionResult also comes with the companion methods from the tree-path module

export declare function isSuccessResult(a: any): a is SuccessResult;
export declare function isFailureResult(a: any): a is FailureResult;

Is the current implementation acceptable?

ddgenome commented 4 years ago

Yes, it seems like this is no longer relevant.