Skip to content

Commit

Permalink
Make createTemplate pure
Browse files Browse the repository at this point in the history
Extracting `options.platform` makes it easier to test without having to
stub `process.platform`.
  • Loading branch information
gasi committed Mar 2, 2018
1 parent 9c26404 commit 9638b86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/menu.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
const isString = require('lodash/isString');


exports.createTemplate = (options, messages) => {
if (!isString(options.platform)) {
throw new TypeError('`options.platform` must be a string');
}

const {
openForums,
openNewBugForm,
openReleaseNotes,
openSupportPage,
platform,
setupAsNewDevice,
setupAsStandalone,
setupWithImport,
Expand Down Expand Up @@ -147,7 +155,7 @@ exports.createTemplate = (options, messages) => {
});
}

if (process.platform === 'darwin') {
if (platform === 'darwin') {
return updateForMac(template, messages, options);
}

Expand Down
2 changes: 2 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ app.on('ready', () => {
});

function setupMenu(options) {
const { platform } = process;
const menuOptions = Object.assign({}, options, {
development,
showDebugLog,
Expand All @@ -444,6 +445,7 @@ function setupMenu(options) {
openNewBugForm,
openSupportPage,
openForums,
platform,
setupWithImport,
setupAsNewDevice,
setupAsStandalone,
Expand Down

0 comments on commit 9638b86

Please sign in to comment.