Skip to content

Commit f34ddac

Browse files
committed
feat(generator): add change-case to paramCase the input appname
1 parent b80a5a9 commit f34ddac

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

generators/app/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
const Generator = require('yeoman-generator');
22
const chalk = require('chalk');
33
const yosay = require('yosay');
4+
const changeCase = require('change-case');
45

56
const pkg = require('../../package.json');
67

78
module.exports = class extends Generator {
89
async prompting() {
910
this.log(yosay(`Welcome to the ${chalk.red(pkg.name)} generator!`));
1011

12+
const appName = changeCase.paramCase(this.appname);
1113
const gitName = this.user.git.name() || 'organization';
1214
const gitEmail = this.user.git.email() || 'hi@domain.com';
1315
const githubUsername = await (async () => {
@@ -24,7 +26,7 @@ module.exports = class extends Generator {
2426
type: 'input',
2527
name: 'elementName',
2628
message: 'Name of this service?',
27-
default: this.appname,
29+
default: appName,
2830
},
2931
{
3032
type: 'input',
@@ -36,13 +38,13 @@ module.exports = class extends Generator {
3638
type: 'input',
3739
name: 'elementHomepage',
3840
message: 'Homepage?',
39-
default: `https://github.com/${githubUsername}/${this.appname}`,
41+
default: `https://github.com/${githubUsername}/${appName}`,
4042
},
4143
{
4244
type: 'input',
4345
name: 'elementBugs',
4446
message: 'Bugs tracker?',
45-
default: `https://github.com/${githubUsername}/${this.appname}/issues`,
47+
default: `https://github.com/${githubUsername}/${appName}/issues`,
4648
},
4749
{
4850
type: 'input',
@@ -54,7 +56,7 @@ module.exports = class extends Generator {
5456
type: 'input',
5557
name: 'elementRepository',
5658
message: 'Repository?',
57-
default: `https://github.com/${githubUsername}/${this.appname}.git`,
59+
default: `https://github.com/${githubUsername}/${appName}.git`,
5860
},
5961
{
6062
type: 'input',

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
},
3333
"devDependencies": {
3434
"@boringcodes/prettier-config": "*",
35+
"change-case": "^4.1.1",
3536
"husky": "^4.2.3",
3637
"prettier": "^2.0.2",
3738
"pretty-quick": "^2.0.1",

0 commit comments

Comments
 (0)