It does noly convert a small set of codes into ES6. You sill need to edit the file.
find ./components -name "*.cjsx" -exec ./converter.sh {} \;
s/(.+) = require[(]? ?(.+)[)]?/import \1 from \2;/ | |
s/module.exports = /export default / | |
s/React.createClass// | |
s/ displayName: "([A-Za-z0-9]+)"/class \1 extends React.Component {/ | |
s/@/this./g | |
s/ (.+): ?->/ \1 () {/ | |
s/ (.+): \((.+)\) ?->/ \1 (\2) {/ | |
s/\((.+)\) ->/function (\1) {/ |
#!/bin/sh | |
cjsx=$1 | |
jsx=`echo $cjsx | sed 's/.cjsx/.jsx/'` | |
sed -E -f coffee2es6.sed $cjsx > $jsx | |
rm $cjsx | |