Skip to content
Permalink
Browse files

refactor(initializer): make init options camelcase

BREAKING CHANGE: Change lintstyle to lintStyle
  • Loading branch information
MarshallOfSound authored and malept committed Aug 27, 2017
1 parent fd6f2f9 commit f44598222a061e99d3a75aa733cd1b66f63dbcc9
Showing with 17 additions and 16 deletions.
  1. +13 −12 src/api/init.js
  2. +3 −3 src/electron-forge-init.js
  3. +1 −1 test/slow/api_spec_slow.js
@@ -15,7 +15,8 @@ const d = debug('electron-forge:init');
* @typedef {Object} InitOptions
* @property {string} [dir=process.cwd()] The path to the app to be initialized
* @property {boolean} [interactive=false] Whether to use sensible defaults or prompt the user visually
* @property {string} [lintstyle=airbnb] The lintstyle to pass through to the template creator
* @property {string} [lintStyle=airbnb] The lintStyle to pass through to the template creator
* @property {boolean} [copyCIFiles=false] Whether to copy Travis and AppVeyor CI files
* @property {string} [template] The custom template to use. If left empty, the default template is used
*/

@@ -27,34 +28,34 @@ const d = debug('electron-forge:init');
*/
export default async (providedOptions = {}) => {
// eslint-disable-next-line prefer-const, no-unused-vars
let { dir, interactive, lintstyle, copycifiles, template } = Object.assign({
let { dir, interactive, lintStyle, copyCIFiles, template } = Object.assign({
dir: process.cwd(),
interactive: false,
lintstyle: 'airbnb',
copycifiles: false,
lintStyle: 'airbnb',
copyCIFiles: false,
template: null,
}, providedOptions);
asyncOra.interactive = interactive;

d(`Initializing in: ${dir}`);

if (!template) {
lintstyle = lintstyle.toLowerCase();
if (!['airbnb', 'standard'].includes(lintstyle)) {
d(`Unrecognized lintstyle argument: '${lintstyle}' -- defaulting to 'airbnb'`);
lintstyle = 'airbnb';
lintStyle = lintStyle.toLowerCase();
if (!['airbnb', 'standard'].includes(lintStyle)) {
d(`Unrecognized lintStyle argument: '${lintStyle}' -- defaulting to 'airbnb'`);
lintStyle = 'airbnb';
}
}

await initDirectory(dir, interactive);
await initGit(dir);
await initStarter(dir, { lintStyle: template ? undefined : lintstyle, copyCIFiles: copycifiles });
await initNPM(dir, template ? undefined : lintstyle);
await initStarter(dir, { lintStyle: template ? undefined : lintStyle, copyCIFiles });
await initNPM(dir, template ? undefined : lintStyle);
if (!template) {
if (lintstyle === 'standard') {
if (lintStyle === 'standard') {
await initStandardFix(dir);
}
} else {
await initCustom(dir, template, lintstyle);
await initCustom(dir, template, lintStyle);
}
};
@@ -10,7 +10,7 @@ import { init } from './api';
.version(require('../package.json').version)
.arguments('[name]')
.option('-t, --template [name]', 'Name of the forge template to use')
.option('-l, --lintstyle [style]', 'Linting standard to follow. For the default template it can be "airbnb" or "standard"', 'airbnb')
.option('-l, --lintStyle [style]', 'Linting standard to follow. For the default template it can be "airbnb" or "standard"', 'airbnb')
.option('-c, --copy-ci-files', 'Whether to copy the templated CI files (defaults to false)', false)
.action((name) => {
if (!name) return;
@@ -25,8 +25,8 @@ import { init } from './api';
const initOpts = {
dir,
interactive: true,
lintstyle: program.lintstyle,
copycifiles: !!program.copyCiFiles,
lintStyle: program.lintStyle,
copyCIFiles: !!program.copyCiFiles,
};
if (program.template) initOpts.template = program.template;

@@ -77,7 +77,7 @@ describe(`electron-forge API (with installer=${installer.substr(12)})`, () => {
forLintingMethod('standard');

describe('init with CI files enabled', () => {
beforeInitTest({ copycifiles: true });
beforeInitTest({ copyCIFiles: true });

it('should copy over the CI config files correctly', async () => {
expect(await fs.pathExists(dir), 'the target dir should have been created').to.equal(true);

0 comments on commit f445982

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