@@ -14,7 +14,7 @@ module.exports.run = function run(opts, cb)
14
14
if ( opts . setup )
15
15
code = opts . setup + ';\n' + code ;
16
16
17
- run ( { name : 'node' , 'args' : [ '-e' , transform ( code ) ] } ) ;
17
+ runNode ( opts , code , run ) ;
18
18
} ,
19
19
testIntegration : function ( run )
20
20
{
@@ -71,6 +71,7 @@ function prepareMocha(opts, interfaceType, run) {
71
71
code += config . snippets . javascript . closure . end ;
72
72
73
73
var solutionFile = util . codeWriteSync ( 'javascript' , transform ( code ) , dir , 'mocha' , true ) ;
74
+ // NOTE: Mocha based testing currently does not support Node versioning
74
75
run ( { name : 'mocha' , 'args' : [ '--harmony' , '-u' , interfaceType , '-R' , 'mocha-reporter' , solutionFile ] } ) ;
75
76
}
76
77
@@ -94,39 +95,79 @@ function prepareCw2(opts, run)
94
95
code += opts . fixture ;
95
96
code += config . snippets . javascript . inlineTestFixture . end ;
96
97
code += config . snippets . javascript . end ;
97
- run ( { name : 'node' , 'args' : [ '-e' , transform ( code ) ] } ) ;
98
+
99
+ runNode ( opts , code , run ) ;
100
+ }
101
+
102
+ function runNode ( opts , code , run ) {
103
+ var version = ( opts . languageVersion || '6.x' ) . split ( '/' ) [ 0 ]
104
+
105
+ // support 6.x/babel
106
+ if ( opts . languageVersion && opts . languageVersion . split ( '/' ) [ 1 ] == 'babel' ) {
107
+ code = transform ( code ) ;
108
+ }
109
+ run ( { name : `/usr/local/n/versions/node/${ nodeVersion ( version ) } /bin/node` , 'args' : [ '-e' , code ] } ) ;
98
110
}
99
111
100
- function transform ( code ) {
112
+ function nodeVersion ( version ) {
113
+ switch ( version ) {
114
+ case "6.x" :
115
+ return "6.0.0" ;
116
+ case "0.10.x" :
117
+ return "0.10.33"
118
+ default :
119
+ return version ;
120
+ }
121
+ }
122
+
123
+ function transform ( code , version ) {
101
124
try {
102
- return require ( 'babel-core' ) . transform ( code , {
103
- presets : [ "stage-1" , "react" ] ,
104
- plugins : [
105
- "transform-runtime" ,
106
- "check-es2015-constants" ,
107
- "transform-es2015-arrow-functions" ,
108
- "transform-es2015-block-scoped-functions" ,
109
- "transform-es2015-block-scoping" ,
110
- "transform-es2015-classes" ,
111
- "transform-es2015-computed-properties" ,
112
- "transform-es2015-destructuring" ,
113
- "transform-es2015-duplicate-keys" ,
114
- "transform-es2015-for-of" ,
115
- "transform-es2015-function-name" ,
116
- "transform-es2015-literals" ,
117
- "transform-es2015-object-super" ,
118
- "transform-es2015-parameters" ,
119
- "transform-es2015-shorthand-properties" ,
120
- "transform-es2015-spread" ,
121
- "transform-es2015-sticky-regex" ,
122
- "transform-es2015-template-literals" ,
123
- "transform-es2015-typeof-symbol" ,
124
- "transform-es2015-unicode-regex" ,
125
- "transform-regenerator" ,
126
- ] ,
127
- ast : false ,
128
- filename : 'kata'
129
- } ) . code ;
125
+ if ( version == '0.10.x' ) {
126
+ return require ( 'babel-core' ) . transform ( code , {
127
+ presets : [ "stage-1" , "react" ] ,
128
+ plugins : [
129
+ "transform-runtime" ,
130
+ "check-es2015-constants" ,
131
+ "angular2-annotations" ,
132
+ "transform-decorators-legacy" ,
133
+ "transform-class-properties" ,
134
+ "transform-flow-strip-types" ,
135
+ "transform-es2015-arrow-functions" ,
136
+ "transform-es2015-block-scoped-functions" ,
137
+ "transform-es2015-block-scoping" ,
138
+ "transform-es2015-classes" ,
139
+ "transform-es2015-computed-properties" ,
140
+ "transform-es2015-destructuring" ,
141
+ "transform-es2015-duplicate-keys" ,
142
+ "transform-es2015-for-of" ,
143
+ "transform-es2015-function-name" ,
144
+ "transform-es2015-literals" ,
145
+ "transform-es2015-object-super" ,
146
+ "transform-es2015-parameters" ,
147
+ "transform-es2015-shorthand-properties" ,
148
+ "transform-es2015-spread" ,
149
+ "transform-es2015-sticky-regex" ,
150
+ "transform-es2015-template-literals" ,
151
+ "transform-es2015-typeof-symbol" ,
152
+ "transform-es2015-unicode-regex" ,
153
+ "transform-regenerator" ,
154
+ ] ,
155
+ ast : false ,
156
+ filename : 'kata'
157
+ } ) . code ;
158
+ } else {
159
+ return require ( 'babel-core' ) . transform ( code , {
160
+ presets : [ "stage-1" , "node5" , "react" ] ,
161
+ plugins : [
162
+ "angular2-annotations" ,
163
+ "transform-decorators-legacy" ,
164
+ "transform-class-properties" ,
165
+ "transform-flow-strip-types" ,
166
+ ] ,
167
+ ast : false ,
168
+ filename : 'kata'
169
+ } ) . code ;
170
+ }
130
171
}
131
172
catch ( ex ) {
132
173
var msg = ex . message ;
0 commit comments