generating es6 modules if --es6 flag is used

This commit is contained in:
Emil Stenberg
2014-12-10 12:45:17 +01:00
parent 7421ef680f
commit 505d7277e9
2 changed files with 12 additions and 1 deletions
+7
View File
@@ -3,12 +3,19 @@ var util = require('util');
var ScriptBase = require('../script-base.js'); var ScriptBase = require('../script-base.js');
var ComponentGenerator = module.exports = function ComponentGenerator(args, options, config) { var ComponentGenerator = module.exports = function ComponentGenerator(args, options, config) {
ScriptBase.apply(this, arguments); ScriptBase.apply(this, arguments);
}; };
util.inherits(ComponentGenerator, ScriptBase); util.inherits(ComponentGenerator, ScriptBase);
ComponentGenerator.prototype.createComponentFile = function createComponentFile() { ComponentGenerator.prototype.createComponentFile = function createComponentFile() {
this.option('es6');
this.es6 = this.options.es6;
console.log('es6:', this.es6)
this.generateSourceAndTest( this.generateSourceAndTest(
'Component', 'Component',
'spec/Component', 'spec/Component',
+5 -1
View File
@@ -19,5 +19,9 @@ var <%= classedName %> = React.createClass({
); );
} }
}); });
<% if (es6) { %>
export default <%= classedName %>;
<% } else { %>
module.exports = <%= classedName %>; module.exports = <%= classedName %>;
<% } %>