Skip to content
This repository was archived by the owner on Mar 26, 2018. It is now read-only.

Commit 4c53c1a

Browse files
committed
feat(decorator): Define creation of decorator at decorator/index.js and added USAGE File
1 parent c9f80b3 commit 4c53c1a

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

decorator/USAGE

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Description:
2+
Creates a new AngularJS decorator for a specified service
3+
4+
Example:
5+
yo angular:decorator serviceName [--coffee]
6+
7+
This will create:
8+
app/scripts/decorators/serviceNameDecorator.js
9+
10+
11+
if you want to use multiple decorator for a service,
12+
you are able to use the second argument
13+
14+
yo angular:decorator serviceName serviceNameLogging [--coffee]
15+
16+
This will create:
17+
app/scripts/decorators/serviceNameLoggingDecorator.js

decorator/index.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
'use strict';
2+
var path = require('path');
3+
var util = require('util');
4+
var ScriptBase = require('../script-base.js');
5+
var angularUtils = require('../util.js');
6+
7+
8+
module.exports = Generator;
9+
10+
function Generator() {
11+
ScriptBase.apply(this, arguments);
12+
var postFix = "Decorator";
13+
14+
//TODO: Any better way in yeoman to get this value?
15+
var fileName = arguments[0][1];
16+
if(fileName === undefined){
17+
fileName = this.name+postFix;
18+
}
19+
else{
20+
fileName += postFix;
21+
}
22+
this.fileName = fileName;
23+
}
24+
25+
util.inherits(Generator, ScriptBase);
26+
27+
Generator.prototype.createDecoratorFiles = function createDecoratorFiles() {
28+
this.appTemplate('decorator', 'scripts/decorators/' + this.fileName);
29+
this.addScriptToIndex('decorators/' + this.fileName);
30+
};

0 commit comments

Comments
 (0)