Skip to content

Commit

Permalink
refactor(initializer): make init options camelcase
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Change lintstyle to lintStyle
  • Loading branch information
MarshallOfSound authored and malept committed Aug 27, 2017
1 parent fd6f2f9 commit f445982
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
25 changes: 13 additions & 12 deletions src/api/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/

Expand All @@ -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);
}
};
6 changes: 3 additions & 3 deletions src/electron-forge-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion test/slow/api_spec_slow.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f445982

Please sign in to comment.