forked from cgross/generator-cg-angular
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
executable file
·58 lines (42 loc) · 1.56 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'use strict';
var util = require('util');
var yeoman = require('yeoman-generator');
var path = require('path');
var cgUtils = require('../utils.js');
var chalk = require('chalk');
var _ = require('underscore');
var fs = require('fs');
_.str = require('underscore.string');
_.mixin(_.str.exports());
var DirectiveGenerator = module.exports = function DirectiveGenerator(args, options, config) {
cgUtils.getNameArg(this,args);
yeoman.generators.Base.apply(this, arguments);
};
util.inherits(DirectiveGenerator, yeoman.generators.Base);
DirectiveGenerator.prototype.askFor = function askFor() {
var cb = this.async();
var prompts = [{
type:'confirm',
name: 'needpartial',
message: 'Does this directive need an external html file (i.e. partial)?',
default: true
}];
cgUtils.addNamePrompt(this,prompts,'directive');
this.prompt(prompts, function (props) {
if (props.name){
this.name = props.name;
}
this.needpartial = props.needpartial;
cgUtils.askForModuleAndDir('directive',this,this.needpartial,cb);
}.bind(this));
};
DirectiveGenerator.prototype.files = function files() {
var configName = 'directiveSimpleTemplates';
var defaultDir = 'templates/simple';
if (this.needpartial) {
configName = 'directiveComplexTemplates';
defaultDir = 'templates/complex';
}
this.htmlPath = path.join(this.dir,this.name + '.html').replace(/\\/g,'/');;
cgUtils.processTemplates(this.name,this.dir,'directive',this,defaultDir,configName,this.module);
};