Skip to content

Commit 272abef

Browse files
committed
feat(gen): add --skip-config flag
1 parent f022e3a commit 272abef

File tree

1 file changed

+38
-31
lines changed

1 file changed

+38
-31
lines changed

src/generators/app/index.js

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ export class Generator extends Base {
1919
constructor(...args) {
2020
super(...args);
2121

22-
this.env.alias('angular-fullstack', 'afs');
23-
this.env.alias('afs', 'angular-fullstack');
24-
2522
this.argument('name', { type: String, required: false });
2623

2724
this.option('skip-install', {
@@ -30,6 +27,12 @@ export class Generator extends Base {
3027
defaults: false
3128
});
3229

30+
this.option('skip-config', {
31+
desc: 'Always use existing .yo-rc.json',
32+
type: Boolean,
33+
defaults: false
34+
});
35+
3336
this.option('app-suffix', {
3437
desc: 'Allow a custom suffix to be added to the module name',
3538
type: String,
@@ -79,34 +82,38 @@ export class Generator extends Base {
7982
checkForConfig: function() {
8083
var existingFilters = this.config.get('filters');
8184

82-
if(existingFilters) {
83-
return this.prompt([{
84-
type: 'confirm',
85-
name: 'skipConfig',
86-
message: 'Existing .yo-rc configuration found, would you like to use it?',
87-
default: true,
88-
}]).then(answers => {
89-
this.skipConfig = answers.skipConfig;
90-
91-
if(this.skipConfig) {
92-
insight.track('skipConfig', 'true');
93-
this.filters = existingFilters;
94-
95-
this.scriptExt = this.filters.ts ? 'ts' : 'js';
96-
this.templateExt = this.filters.jade ? 'jade' : 'html';
97-
this.styleExt = this.filters.sass ? 'scss' :
98-
this.filters.less ? 'less' :
99-
this.filters.stylus ? 'styl' :
100-
'css';
101-
} else {
102-
insight.track('skipConfig', 'false');
103-
this.filters = {};
104-
this.forceConfig = true;
105-
this.config.set('filters', this.filters);
106-
this.config.forceSave();
107-
}
108-
});
109-
}
85+
if(!existingFilters) return;
86+
87+
let promise = this.options['skip-config']
88+
? Promise.resolve({skipConfig: true})
89+
: this.prompt([{
90+
type: 'confirm',
91+
name: 'skipConfig',
92+
message: 'Existing .yo-rc configuration found, would you like to use it?',
93+
default: true,
94+
}]);
95+
96+
promise.then(answers => {
97+
this.skipConfig = answers.skipConfig;
98+
99+
if(this.skipConfig) {
100+
insight.track('skipConfig', 'true');
101+
this.filters = existingFilters;
102+
103+
this.scriptExt = this.filters.ts ? 'ts' : 'js';
104+
this.templateExt = this.filters.jade ? 'jade' : 'html';
105+
this.styleExt = this.filters.sass ? 'scss' :
106+
this.filters.less ? 'less' :
107+
this.filters.stylus ? 'styl' :
108+
'css';
109+
} else {
110+
insight.track('skipConfig', 'false');
111+
this.filters = {};
112+
this.forceConfig = true;
113+
this.config.set('filters', this.filters);
114+
this.config.forceSave();
115+
}
116+
});
110117
}
111118
};
112119
}

0 commit comments

Comments
 (0)