Skip to content

Commit e5264e9

Browse files
committed
default "bin name" to "name"
1 parent e12e162 commit e5264e9

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

generators/app/index.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ module.exports = class extends Generator {
2424
this.description = {
2525
type: String,
2626
alias: "d",
27-
desc: "Command line app description (e.g. )"
27+
desc: "Command line app description"
2828
};
2929

3030
this.argument("name", this.name);
@@ -37,24 +37,7 @@ module.exports = class extends Generator {
3737
prompting() {
3838
this.log(yosay("Welcome to the " + chalk.blue("node-cli-commander") + " generator!"));
3939

40-
const prompts = [];
41-
42-
if (!this.options.description) {
43-
prompts.unshift({
44-
type: "input",
45-
name: "description",
46-
message: this.description.desc,
47-
default: "Command line tool"
48-
});
49-
}
50-
51-
if (!this.options.binName) {
52-
prompts.unshift({
53-
type: "input",
54-
name: "binName",
55-
message: this.binName.desc
56-
});
57-
}
40+
let prompts = [];
5841

5942
if (!this.options.name) {
6043
prompts.unshift({
@@ -66,9 +49,32 @@ module.exports = class extends Generator {
6649

6750
return this.prompt(prompts).then(answer => {
6851
this.name = this.options.name || answer.name;
69-
this.binName = this.options.binName || answer.binName;
70-
this.description = this.options.description || answer.description;
7152
this.dir = this.name;
53+
54+
prompts = [];
55+
56+
if (!this.options.description) {
57+
prompts.unshift({
58+
type: "input",
59+
name: "description",
60+
message: this.description.desc,
61+
default: "Command line tool"
62+
});
63+
}
64+
65+
if (!this.options.binName) {
66+
prompts.unshift({
67+
type: "input",
68+
name: "binName",
69+
message: this.binName.desc,
70+
default: this.name
71+
});
72+
}
73+
74+
return this.prompt(prompts).then(answer => {
75+
this.binName = this.options.binName || answer.binName;
76+
this.description = this.options.description || answer.description;
77+
});
7278
});
7379
}
7480

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "generator-node-cli-commander",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "Node command line application generator using commander.js",
55
"homepage": "https://github.com/clarketm/generator-node-cli-commander.git",
66
"author": {

0 commit comments

Comments
 (0)