From f44598222a061e99d3a75aa733cd1b66f63dbcc9 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Sun, 27 Aug 2017 10:36:17 +1000 Subject: [PATCH] refactor(initializer): make init options camelcase BREAKING CHANGE: Change lintstyle to lintStyle --- src/api/init.js | 25 +++++++++++++------------ src/electron-forge-init.js | 6 +++--- test/slow/api_spec_slow.js | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/api/init.js b/src/api/init.js index 5ca739c943..6b9db589f7 100644 --- a/src/api/init.js +++ b/src/api/init.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,11 +28,11 @@ 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; @@ -39,22 +40,22 @@ export default async (providedOptions = {}) => { 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); } }; diff --git a/src/electron-forge-init.js b/src/electron-forge-init.js index d57ddfb527..a8143bf86f 100644 --- a/src/electron-forge-init.js +++ b/src/electron-forge-init.js @@ -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; diff --git a/test/slow/api_spec_slow.js b/test/slow/api_spec_slow.js index ea8f5d4661..a1cbfc04d3 100644 --- a/test/slow/api_spec_slow.js +++ b/test/slow/api_spec_slow.js @@ -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);