diff --git a/decorator/USAGE b/decorator/USAGE new file mode 100644 index 000000000..8dce22348 --- /dev/null +++ b/decorator/USAGE @@ -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 \ No newline at end of file diff --git a/decorator/index.js b/decorator/index.js new file mode 100644 index 000000000..7fce45464 --- /dev/null +++ b/decorator/index.js @@ -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); +};