Make `createTemplate` pure

Extracting `options.platform` makes it easier to test without having to
stub `process.platform`.
This commit is contained in:
Daniel Gasienica 2018-02-27 12:34:46 -05:00
parent 9c26404892
commit 9638b86c0f
2 changed files with 11 additions and 1 deletions

View File

@ -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);
}

View File

@ -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,