This repository has been archived by the owner on Mar 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(decorator): Define creation of decorator at decorator/index.js a…
…nd added USAGE File
- Loading branch information
1 parent
c9f80b3
commit 4c53c1a
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}; |