Skip to content

Commit 8874722

Browse files
stephenpluspluspassy
authored andcommitted
build(app): use new prompts
1 parent e0c03d5 commit 8874722

File tree

2 files changed

+54
-73
lines changed

2 files changed

+54
-73
lines changed

app/index.js

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,11 @@ Generator.prototype.askForBootstrap = function askForBootstrap() {
7777
var cb = this.async();
7878

7979
this.prompt({
80+
type: 'confirm',
8081
name: 'bootstrap',
8182
message: 'Would you like to include Twitter Bootstrap?',
82-
default: true,
83-
warning: 'Yes: All Twitter Bootstrap files will be placed into the styles directory.'
84-
}, function (err, props) {
85-
if (err) {
86-
return this.emit('error', err);
87-
}
88-
83+
default: true
84+
}, function (props) {
8985
this.bootstrap = props.bootstrap;
9086

9187
cb();
@@ -100,15 +96,11 @@ Generator.prototype.askForCompass = function askForCompass() {
10096
var cb = this.async();
10197

10298
this.prompt({
99+
type: 'confirm',
103100
name: 'compassBootstrap',
104101
message: 'If so, would you like to use Twitter Bootstrap for Compass (as opposed to vanilla CSS)?',
105-
default: true,
106-
warning: 'Yes: All Twitter Bootstrap files will be placed into the styles directory.'
107-
}, function (err, props) {
108-
if (err) {
109-
return this.emit('error', err);
110-
}
111-
102+
default: true
103+
}, function (props) {
112104
this.compassBootstrap = props.compassBootstrap;
113105

114106
cb();
@@ -119,27 +111,23 @@ Generator.prototype.askForModules = function askForModules() {
119111
var cb = this.async();
120112

121113
var prompts = [{
114+
type: 'confirm',
122115
name: 'resourceModule',
123116
message: 'Would you like to include angular-resource.js?',
124-
default: true,
125-
warning: 'Yes: angular-resource added to bower.json'
117+
default: true
126118
}, {
119+
type: 'confirm',
127120
name: 'cookiesModule',
128121
message: 'Would you like to include angular-cookies.js?',
129-
default: true,
130-
warning: 'Yes: angular-cookies added to bower.json'
122+
default: true
131123
}, {
124+
type: 'confirm',
132125
name: 'sanitizeModule',
133126
message: 'Would you like to include angular-sanitize.js?',
134-
default: true,
135-
warning: 'Yes: angular-sanitize added to bower.json'
127+
default: true
136128
}];
137129

138-
this.prompt(prompts, function (err, props) {
139-
if (err) {
140-
return this.emit('error', err);
141-
}
142-
130+
this.prompt(prompts, function (props) {
143131
this.resourceModule = props.resourceModule;
144132
this.cookiesModule = props.cookiesModule;
145133
this.sanitizeModule = props.sanitizeModule;

decorator/index.js

Lines changed: 41 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,71 +4,64 @@ var ScriptBase = require('../script-base.js');
44
var fs = require('fs');
55

66
var Generator = module.exports = function Generator(args, options) {
7-
ScriptBase.apply(this, arguments);
8-
this.fileName = this.name;
7+
ScriptBase.apply(this, arguments);
8+
this.fileName = this.name;
99
};
1010

1111
util.inherits(Generator, ScriptBase);
1212

1313
Generator.prototype.askForOverwrite = function askForOverwrite() {
14-
var cb = this.async();
14+
var cb = this.async();
1515

16-
// TODO: Any yeoman.util function to handle this?
17-
var fileExists = fs.existsSync(this.env.cwd + '/app/scripts/' + buildRelativePath(this.fileName) + ".js");
18-
if (fileExists) {
19-
var prompts = [{
20-
name : 'overwriteDecorator',
21-
message: 'Would you like to overwrite existing decorator?',
22-
default: 'Y/n',
23-
warning: 'Yes: Decorator will be replaced.'
24-
}];
16+
// TODO: Any yeoman.util function to handle this?
17+
var fileExists = fs.existsSync(this.env.cwd + '/app/scripts/' + buildRelativePath(this.fileName) + ".js");
18+
if (fileExists) {
19+
var prompts = [{
20+
type: 'confirm',
21+
name: 'overwriteDecorator',
22+
message: 'Would you like to overwrite existing decorator?',
23+
default: false
24+
}];
2525

26-
this.prompt(prompts, function (err, props) {
27-
if (err) {
28-
return this.emit('error', err);
29-
}
26+
this.prompt(prompts, function (props) {
27+
this.overwriteDecorator = props.overwriteDecorator;
3028

31-
this.overwriteDecorator = (/y/i).test(props.overwriteDecorator);
32-
33-
cb();
34-
}.bind(this));
35-
}
36-
else{
37-
cb();
38-
return;
39-
}
29+
cb();
30+
}.bind(this));
31+
}
32+
else{
33+
cb();
34+
return;
35+
}
4036
};
4137

4238
Generator.prototype.askForNewName = function askForNewName() {
43-
var cb = this.async();
39+
var cb = this.async();
4440

45-
if (this.overwriteDecorator === undefined || this.overwriteDecorator === true) {
46-
cb();
47-
return;
48-
}
49-
else {
50-
var prompts = [];
51-
prompts.push({
52-
name : 'decortatorName',
53-
message: 'Alternative name for the decorator:'
54-
});
41+
if (this.overwriteDecorator === undefined || this.overwriteDecorator === true) {
42+
cb();
43+
return;
44+
}
45+
else {
46+
var prompts = [];
47+
prompts.push({
48+
name: 'decoratorName',
49+
message: 'Alternative name for the decorator'
50+
});
5551

56-
this.prompt(prompts, function (err, props) {
57-
if (err) {
58-
return this.emit('error', err);
59-
}
60-
this.fileName = props.decortatorName;
52+
this.prompt(prompts, function (props) {
53+
this.fileName = props.decoratorName;
6154

62-
cb();
63-
}.bind(this));
64-
}
55+
cb();
56+
}.bind(this));
57+
}
6558
};
6659

6760
Generator.prototype.createDecoratorFiles = function createDecoratorFiles() {
68-
this.appTemplate('decorator', 'scripts/' + buildRelativePath(this.fileName));
69-
this.addScriptToIndex(buildRelativePath(this.fileName));
61+
this.appTemplate('decorator', 'scripts/' + buildRelativePath(this.fileName));
62+
this.addScriptToIndex(buildRelativePath(this.fileName));
7063
};
7164

7265
function buildRelativePath(fileName){
73-
return 'decorators/' + fileName + "Decorator";
74-
}
66+
return 'decorators/' + fileName + "Decorator";
67+
}

0 commit comments

Comments
 (0)