Skip to content

Commit 6581870

Browse files
Oatelausadmtorgst
authored andcommitted
import eta templates as javascript strings (github#648)
1 parent b931b8c commit 6581870

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

lib/commentmessage.eta renamed to lib/commentmessage.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
* Run on: `<%= new Date() %>`
1+
module.exports = `* Run on: \` <%= new Date() %> \`
22
3-
* Number of repos that were considered: `<%= Object.keys(it.reposProcessed).length %>`
3+
* Number of repos that were considered: \`<%= Object.keys(it.reposProcessed).length %> \`
44
55
### Breakdown of changes
66
| Repo <% Object.keys(it.changes).forEach(plugin => { %> | <%= plugin %> settings <% }) %> |
@@ -19,7 +19,7 @@
1919
### Breakdown of errors
2020
2121
<% if (Object.keys(it.errors).length === 0) { %>
22-
`None`
22+
\`None\`
2323
<% } else { %>
2424
<% Object.keys(it.errors).forEach(repo => { %>
2525
<%_= repo %>:
@@ -28,6 +28,4 @@
2828
<% }) %>
2929
3030
<% }) %>
31-
<% } %>
32-
33-
31+
<% } %>`

lib/error.eta renamed to lib/error.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Run on: `<%= new Date().toISOString() %>`
1+
module.exports = `Run on: \`<%= new Date().toISOString() %>\`
22
33
#### Breakdown of Errors
44
| Owner| Repo | Plugin | Error
@@ -9,3 +9,4 @@ Run on: `<%= new Date().toISOString() %>`
99
<% }) -%>
1010
1111
12+
`

lib/settings.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const path = require('path')
22
const { Eta } = require('eta')
3+
const commetMessageTemplate = require('./commentmessage')
4+
const errorTemplate = require('./error')
35
const Glob = require('./glob')
46
const NopCommand = require('./nopcommand')
57
const MergeDeep = require('./mergeDeep')
@@ -103,7 +105,7 @@ class Settings {
103105
if (this.errors.length > 0) {
104106
conclusion = 'failure'
105107
summary = 'Safe-Settings finished with errors.'
106-
details = await eta.render('./error', this.errors)
108+
details = await eta.renderString(errorTemplate, this.errors)
107109
}
108110

109111
// Use the latest commit to create the check against
@@ -217,7 +219,7 @@ class Settings {
217219
<tbody>
218220
`
219221

220-
const commentmessage = await eta.render('./commentmessage', stats)
222+
const renderedCommentMessage = await eta.renderString(commetMessageTemplate, stats)
221223

222224
if (env.CREATE_PR_COMMENT === 'true') {
223225
const summary = `
@@ -262,7 +264,7 @@ ${this.results.reduce((x, y) => {
262264
completed_at: new Date().toISOString(),
263265
output: {
264266
title: error ? 'Safe-Settings Dry-Run Finished with Error' : 'Safe-Settings Dry-Run Finished with success',
265-
summary: commentmessage.length > 55536 ? `${commentmessage.substring(0, 55536)}... (too many changes to report)` : commentmessage
267+
summary: renderedCommentMessage.length > 55536 ? `${renderedCommentMessage.substring(0, 55536)}... (too many changes to report)` : renderedCommentMessage
266268
}
267269
}
268270

0 commit comments

Comments
 (0)