#!/usr/bin/env node
// -*- mode: js -*-
"use strict";

var visitors = require('../vendor/fbtransform/visitors');
var transform = require('jstransform').transform;

require('commoner').version(
  require('../package.json').version
).resolve(function(id) {
  return this.readModuleP(id);
}).option(
  '--harmony',
  'Turns on JS transformations such as ES6 Classes etc.'
).process(function(id, source) {
  // This is where JSX, ES6, etc. desugaring happens.
  var visitorList;
  if (this.options.harmony) {
    visitorList = visitors.getAllVisitors();
  } else {
    visitorList = visitors.transformVisitors.react;
  }
  return transform(visitorList, source).code;
});
