Make `createTemplate` pure
Extracting `options.platform` makes it easier to test without having to stub `process.platform`.
This commit is contained in:
parent
9c26404892
commit
9638b86c0f
10
app/menu.js
10
app/menu.js
|
@ -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,
|
||||
|
@ -147,7 +155,7 @@ exports.createTemplate = (options, messages) => {
|
|||
});
|
||||
}
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
if (platform === 'darwin') {
|
||||
return updateForMac(template, messages, options);
|
||||
}
|
||||
|
||||
|
|
2
main.js
2
main.js
|
@ -435,6 +435,7 @@ app.on('ready', () => {
|
|||
});
|
||||
|
||||
function setupMenu(options) {
|
||||
const { platform } = process;
|
||||
const menuOptions = Object.assign({}, options, {
|
||||
development,
|
||||
showDebugLog,
|
||||
|
@ -444,6 +445,7 @@ function setupMenu(options) {
|
|||
openNewBugForm,
|
||||
openSupportPage,
|
||||
openForums,
|
||||
platform,
|
||||
setupWithImport,
|
||||
setupAsNewDevice,
|
||||
setupAsStandalone,
|
||||
|
|
Loading…
Reference in New Issue