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

Commit

Permalink
feat(decorator): Define creation of decorator at decorator/index.js a…
Browse files Browse the repository at this point in the history
…nd added USAGE File
  • Loading branch information
robinboehm committed Apr 29, 2013
1 parent c9f80b3 commit 4c53c1a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
17 changes: 17 additions & 0 deletions decorator/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Description:
Creates a new AngularJS decorator for a specified service

Example:
yo angular:decorator serviceName [--coffee]

This will create:
app/scripts/decorators/serviceNameDecorator.js


if you want to use multiple decorator for a service,
you are able to use the second argument

yo angular:decorator serviceName serviceNameLogging [--coffee]

This will create:
app/scripts/decorators/serviceNameLoggingDecorator.js
30 changes: 30 additions & 0 deletions decorator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';
var path = require('path');
var util = require('util');
var ScriptBase = require('../script-base.js');
var angularUtils = require('../util.js');


module.exports = Generator;

function Generator() {
ScriptBase.apply(this, arguments);
var postFix = "Decorator";

//TODO: Any better way in yeoman to get this value?
var fileName = arguments[0][1];
if(fileName === undefined){
fileName = this.name+postFix;
}
else{
fileName += postFix;
}
this.fileName = fileName;
}

util.inherits(Generator, ScriptBase);

Generator.prototype.createDecoratorFiles = function createDecoratorFiles() {
this.appTemplate('decorator', 'scripts/decorators/' + this.fileName);
this.addScriptToIndex('decorators/' + this.fileName);
};

0 comments on commit 4c53c1a

Please sign in to comment.