Skip to content
This repository has been archived by the owner on Mar 19, 2019. It is now read-only.

Commit

Permalink
Prep for 0.23.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kipz committed Apr 11, 2017
1 parent dcd9177 commit b4146b8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 42 deletions.
69 changes: 29 additions & 40 deletions operations/messages/MessageRendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,16 @@ const listIssues = `{
function renderIssues(issuesList: Issue[], chatSystem?: string): string {
const last = "last";
issuesList[issuesList.length - 1][last] = true; // horrible mustache hack
try {
return mustache.render(listIssues, {
assignee() {
return this.assignee !== undefined;
},
closed() {
return this.state === "closed";
},
issues: issuesList,
});
} catch (ex) {
return `Failed to render message using template: ${ex}`;
}

return mustache.render(listIssues, {
assignee() {
return this.assignee !== undefined;
},
closed() {
return this.state === "closed";
},
issues: issuesList,
});
}

const failure = `{
Expand All @@ -89,41 +86,33 @@ const failure = `{
* Generic error rendering.
*/
function renderError(msg: string, corrid?: string, chatSystem?: string): string {
try {
return mustache.render(failure, {
corrid,
hasCorrelationId() {
return this.corrid !== undefined;
},
text: msg,
});
} catch (ex) {
return `Failed to render message using template: ${ex}`;
}
return mustache.render(failure, {
corrid,
hasCorrelationId() {
return this.corrid !== undefined;
},
text: msg,
});
}

const success = `{
"attachments": [
{
"fallback": "{{{text}}}",
"mrkdwn_in": ["text", "pretext"],
"author_name": "Successfully ran command",
"author_icon": "https://images.atomist.com/rug/check-circle.gif?gif={{random}}",
"color": "#45B254",
"text": "{{{text}}}"
}
]
}`;
"attachments": [
{
"fallback": "{{{text}}}",
"mrkdwn_in": ["text", "pretext"],
"author_name": "Successfully ran command",
"author_icon": "https://images.atomist.com/rug/check-circle.gif?gif={{random}}",
"color": "#45B254",
"text": "{{{text}}}"
}
]
} `;

/**
* Generic success rendering.
*/
function renderSuccess(msg: string, chatSystem?: string): string {
try {
return mustache.render(success, { text: msg });
} catch (ex) {
return `Failed to render message using template: ${ex}`;
}
return mustache.render(success, { text: msg });
}

export { renderIssues, renderError, renderSuccess };
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "@atomist/rugs",
"version": "0.22.0",
"version": "0.23.0",
"description": "Helper functions for Rugs",
"dependencies": {
"@atomist/cortex": "0.26.0",
"@atomist/cortex": "0.30.0",
"@atomist/rug": "0.25.0",
"mustache": "^2.3.0"
},
Expand Down

0 comments on commit b4146b8

Please sign in to comment.