Wk-notes-01-10-codemod
A Confusion
nodemon
is a js lib used for node that watch the files change and reload.
'Codemods' are scripts used to rewrite other scripts.
Codemod
An advanced find-and-replace and a better one than 'sed'.
jscodeshift
Batch javascript code manipulating providing its ast. A wrapper of recast
(a AST-to-AST tool)
// transform-script.js
export default (fileInfo, api) => {
const j = api.jscodeshift;
const root = j(fileInfo.source)
return root.find(j.CallExpression, {
callee: {
type: 'MemberExpression',
object: { type: 'Identifier', name: 'console' },
},
}
)
.remove()
.toSource();
};
Last updated
Was this helpful?