Skip to content
Permalink
Browse files

fix(importer): adjust Forge config defaults just like in init

ISSUES CLOSED: #354
  • Loading branch information
malept committed Oct 25, 2017
1 parent dbc2a4b commit 38f9a3d4734fb4da1ad1aff9b9d55607fc0f397e
Showing with 16 additions and 4 deletions.
  1. +2 −0 src/api/import.js
  2. +2 −4 src/init/init-npm.js
  3. +12 −0 src/util/forge-config.js
@@ -6,6 +6,7 @@ import path from 'path';
import initGit from '../init/init-git';
import { deps, devDeps, exactDevDeps } from '../init/init-npm';

import { setInitialForgeConfig } from '../util/forge-config';
import asyncOra from '../util/ora-handler';
import { info, warn } from '../util/messages';
import installDepList from '../util/install-dependencies';
@@ -191,6 +192,7 @@ export default async (providedOptions = {}) => {
packageJSON.config = packageJSON.config || {};
const templatePackageJSON = await readPackageJSON(path.resolve(__dirname, '../../tmpl'));
packageJSON.config.forge = templatePackageJSON.config.forge;
setInitialForgeConfig(packageJSON);

await writeChanges();

@@ -3,10 +3,10 @@ import fs from 'fs-extra';
import path from 'path';
import username from 'username';

import { setInitialForgeConfig } from '../util/forge-config';
import installDepList from '../util/install-dependencies';
import readPackageJSON from '../util/read-package-json';
import asyncOra from '../util/ora-handler';
import yarnOrNpm from '../util/yarn-or-npm';

const d = debug('electron-forge:init:npm');

@@ -21,10 +21,8 @@ export default async (dir, lintStyle) => {
await asyncOra('Initializing NPM Module', async () => {
const packageJSON = await readPackageJSON(path.resolve(__dirname, '../../tmpl'));
packageJSON.productName = packageJSON.name = path.basename(dir).toLowerCase();
packageJSON.config.forge.electronWinstallerConfig.name = packageJSON.name.replace(/-/g, '_');
packageJSON.config.forge.windowsStoreConfig.name = packageJSON.productName.replace(/-/g, '');
packageJSON.config.forge.electronPackagerConfig.packageManager = yarnOrNpm();
packageJSON.author = await username();
setInitialForgeConfig(packageJSON);

switch (lintStyle) {
case 'standard':
@@ -2,6 +2,7 @@ import fs from 'fs-extra';
import path from 'path';
import _template from 'lodash.template';
import readPackageJSON from './read-package-json';
import yarnOrNpm from './yarn-or-npm';

const underscoreCase = str => str.replace(/(.)([A-Z][a-z]+)/g, '$1_$2').replace(/([a-z0-9])([A-Z])/g, '$1_$2').toUpperCase();

@@ -37,6 +38,17 @@ const proxify = (object, envPrefix) => {
});
};

/**
* Sets sensible defaults for the `config.forge` object.
*/
export function setInitialForgeConfig(packageJSON) {
/* eslint-disable no-param-reassign */
packageJSON.config.forge.electronWinstallerConfig.name = packageJSON.name.replace(/-/g, '_');
packageJSON.config.forge.windowsStoreConfig.name = packageJSON.productName.replace(/-/g, '');
packageJSON.config.forge.electronPackagerConfig.packageManager = yarnOrNpm();
/* eslint-enable no-param-reassign */
}

export default async (dir) => {
const packageJSON = await readPackageJSON(dir);
let forgeConfig = packageJSON.config.forge;

0 comments on commit 38f9a3d

Please sign in to comment.
You can’t perform that action at this time.