How to use the recast.run function in recast

To help you get started, we’ve selected a few recast examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / react / vendor / constants.js View on Github external
if (node.test.value) {
        node.alternate = null;
      } else if (node.alternate) {
        this.replace(node.alternate);
        return false;
      } else {
        this.replace(); // Remove the if-statement.
        return false;
      }
    }
  });
}

if (!module.parent) {
  var constants = JSON.parse(process.argv[3]);
  recast.run(function(ast, callback) {
    callback(transform(ast, constants));
  });
}

exports.propagate = propagate;
exports.transform = transform;