How can I convert the node to javascript?
// target file
function execute() {
var a = 'a'
}
// jscodeshift
export default(file, api) => {
const j = api.jscodeshift
const root = j(file.source)
var node = root.find(j.VariableDeclaration)
// i want to see what node looks like in javascript.
return root.toSource()
}
Presumable there is a non empty collection of what you search for:
var node = root.find(j.VariableDeclaration).at(0).get();
// in js node looks like
return j(node).toSource();