Skip to content

Commit fb915b2

Browse files
committed
fix(gen): endpointDirectory is now a full option/config
1 parent 08467ce commit fb915b2

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ var AngularFullstackGenerator = yeoman.generators.Base.extend({
316316

317317
saveSettings: function() {
318318
if(this.skipConfig) return;
319+
this.config.set('endpointDirectory', 'server/api/');
319320
this.config.set('insertRoutes', true);
320321
this.config.set('registerRoutesFile', 'server/routes.js');
321322
this.config.set('routesNeedle', '// Insert routes below');

endpoint/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ var ScriptBase = require('../script-base.js');
77

88
var Generator = module.exports = function Generator() {
99
ScriptBase.apply(this, arguments);
10+
11+
this.option('endpointDirectory', {
12+
desc: 'Parent directory for enpoints',
13+
type: String
14+
});
1015
};
1116

1217
util.inherits(Generator, ScriptBase);
@@ -66,10 +71,14 @@ Generator.prototype.prompting = function askFor() {
6671
}.bind(this));
6772
};
6873

74+
Generator.prototype.configuring = function config() {
75+
this.routeDest = path.join(this.options.endpointDirectory ||
76+
this.config.get('endpointDirectory') || 'server/api/', this.name);
77+
};
78+
6979
Generator.prototype.writing = function createFiles() {
70-
var dest = this.config.get('endpointDirectory') || 'server/api/' + this.name;
7180
this.sourceRoot(path.join(__dirname, './templates'));
72-
ngUtil.processDirectory(this, '.', dest);
81+
ngUtil.processDirectory(this, '.', this.routeDest);
7382
};
7483

7584
Generator.prototype.end = function registerEndpoint() {

0 commit comments

Comments
 (0)