File tree Expand file tree Collapse file tree 3 files changed +28
-15
lines changed
Expand file tree Collapse file tree 3 files changed +28
-15
lines changed Original file line number Diff line number Diff line change 11export class Decorator {
2+
3+ public static isValid ( decoratorKindString : string ) : boolean {
4+ return this . getDecoratorKind ( decoratorKindString ) !== undefined ;
5+ }
6+
7+ public static getDecoratorKind ( decoratorKindString : string ) : DecoratorKind {
8+ switch ( decoratorKindString . toLowerCase ( ) ) {
9+ case "extension" : return DecoratorKind . Extension ;
10+ case "metaextension" : return DecoratorKind . MetaExtension ;
11+ case "customconstructor" : return DecoratorKind . CustomConstructor ;
12+ case "compilemembersonly" : return DecoratorKind . CompileMembersOnly ;
13+ case "pureabstract" : return DecoratorKind . PureAbstract ;
14+ case "phantom" : return DecoratorKind . Phantom ;
15+ case "tuplereturn" : return DecoratorKind . TupleReturn ;
16+ case "noclassor" : return DecoratorKind . NoClassOr ;
17+ }
18+
19+ return undefined ;
20+ }
21+
222 public kind : DecoratorKind ;
323 public args : string [ ] ;
424
5- constructor ( raw : string ) {
6- let nameEnd = raw . indexOf ( " " ) ;
7- if ( nameEnd === - 1 ) {
8- nameEnd = raw . length ;
9- }
10- this . kind = DecoratorKind [ raw . substring ( 0 , nameEnd ) ] ;
11- this . args = raw . split ( " " ) . slice ( 1 ) ;
25+ constructor ( name : string , args : string [ ] ) {
26+ this . kind = Decorator . getDecoratorKind ( name ) ;
27+ this . args = args ;
1228 }
1329}
1430
Original file line number Diff line number Diff line change @@ -117,8 +117,9 @@ export class TSHelper {
117117 const decMap = new Map < DecoratorKind , Decorator > ( ) ;
118118
119119 decorators . forEach ( decStr => {
120- const dec = new Decorator ( decStr . substr ( 1 ) ) ;
121- if ( dec . kind !== undefined ) {
120+ const [ decoratorName , ...decoratorArguments ] = decStr . split ( " " ) ;
121+ if ( Decorator . isValid ( decoratorName . substr ( 1 ) ) ) {
122+ const dec = new Decorator ( decoratorName . substr ( 1 ) , decoratorArguments ) ;
122123 decMap . set ( dec . kind , dec ) ;
123124 console . warn ( `[Deprecated] Decorators with ! are being deprecated, `
124125 + `use @${ decStr . substr ( 1 ) } instead` ) ;
@@ -128,8 +129,8 @@ export class TSHelper {
128129 } ) ;
129130
130131 type . symbol . getJsDocTags ( ) . forEach ( tag => {
131- const dec = new Decorator ( tag . name ) ;
132- if ( dec . kind !== undefined ) {
132+ if ( Decorator . isValid ( tag . name ) ) {
133+ const dec = new Decorator ( tag . name , tag . text . split ( " " ) ) ;
133134 decMap . set ( dec . kind , dec ) ;
134135 }
135136 } ) ;
Original file line number Diff line number Diff line change 11import { TestRunner , TestSet } from "alsatian" ;
2- import { TapBark } from "tap-bark" ;
32
43import * as fs from "fs" ;
54import * as path from "path" ;
@@ -21,9 +20,6 @@ fs.copyFileSync(
2120
2221// setup the output
2322testRunner . outputStream
24- // this will use alsatian's default output if you remove this
25- // you'll get TAP or you can add your favourite TAP reporter in it's place
26- . pipe ( TapBark . create ( ) . getPipeable ( ) )
2723 // pipe to the console
2824 . pipe ( process . stdout ) ;
2925
You can’t perform that action at this time.
0 commit comments