Usage:
$ npx jscodeshift -t https://gist.githubusercontent.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983/raw/eaa64c55dfcda8006fc760054055372bb3109d1c/transform.js test.jsSee https://github.com/facebook/jscodeshift#usage-cli for further details.
Usage:
$ npx jscodeshift -t https://gist.githubusercontent.com/novemberborn/c2cdc94020083a1cafe3f41e8276f983/raw/eaa64c55dfcda8006fc760054055372bb3109d1c/transform.js test.jsSee https://github.com/facebook/jscodeshift#usage-cli for further details.
| module.exports = (fileInfo, {jscodeshift: j}) => { | |
| const ast = j(fileInfo.source) | |
| ast.find(j.CallExpression, { | |
| callee: { | |
| object: {name: 't'}, | |
| property: {name: 'throws'} | |
| } | |
| }).filter(p => p.parentPath.value.type === 'AwaitExpression') | |
| .forEach(p => { | |
| p.get('callee').get('property').replace(j.identifier('throwsAsync')) | |
| }) | |
| ast.find(j.CallExpression, { | |
| callee: { | |
| object: {name: 't'}, | |
| property: {name: 'notThrows'} | |
| } | |
| }).filter(p => p.parentPath.value.type === 'AwaitExpression') | |
| .forEach(p => { | |
| p.get('callee').get('property').replace(j.identifier('notThrowsAsync')) | |
| }) | |
| return ast.toSource() | |
| } |