refactor(electron-forge/deb): make desktop.ejs easier to read

in theory we could use variables in ejs, but unfortunately electron uses lodash template to create the file, which itself DOES NOT like any let/const/var assignments – wasted a bit of time finding this out, before coming up with this solution
This commit is contained in:
Panagiotis Papadopoulos 2025-02-02 12:47:27 +01:00
parent a2f1d71754
commit 61e56023d4

View File

@ -1,12 +1,17 @@
[Desktop Entry]
<% if (productName) { %>Name=<%= productName %>
<% } %><% if (description) { %>Comment=<%= description %>
<% } %><% if (genericName) { %>GenericName=<%= genericName %>
<% } %><% if (name) { %>Exec=<%= name %> %U
Icon=<%= name %>
<% } %>Type=Application
StartupNotify=true
<% if (productName) { %>StartupWMClass=<%= productName %>
<% } if (categories && categories.length) { %>Categories=<%= categories.join(';') %>;
<% } %><% if (mimeType && mimeType.length) { %>MimeType=<%= mimeType.join(';') %>;
<% } %>
<%=
Object.entries({
"Name": productName,
"Comment": description,
"GenericName": genericName,
"Exec": name ? `${name} %U` : undefined,
"Icon": name,
"Type": "Application",
"StartupNotify": "true",
"StartupWMClass": productName,
"Categories": categories?.length ? `${categories.join(";")};` : undefined,
"MimeType": mimeType?.length ? `${mimeType.join(";")};` : undefined
})
.map(line => line[1] ? line.join("=") : undefined)
.filter(line => !!line)
.join("\n")%>