comby-wrapper
v2.1.0
Published
Wrapper around [Comby](https://github.com/comby-tools/comby). Comby is a tool for searching and changing code structure
Downloads
7
Readme
Comby Wrapper
Wrapper around Comby. Comby is a tool for searching and changing code structure
Quckstart
- Install Comby Server
git clone https://github.com/obenjiro/comby-server.git
cd comby-server
docker-compose up
- Install comby-wrapper and rambdax
npm i comby-wrapper, rambdax
- Create script file (script.js) and import comby-wrapper and install functional helper lib (I recommend you to use rambdax)
const CW = require('comby-wrapper');
const R = require('rambdax');
- Write other code for the script file (script.js)
async function main() {
const files = await CW.getFiles(["./react_app/**/*.js"], {
ignore: ['**/node_modules/**']
});
await R.pipedAsync(
files,
// query
CW.match(`const :[[cname]] = props => {:[hole]}`),
// here we preparing replacments
CW.replaceWithSmartIndent(`class :[[cname]] extends React.Component {
render() {
const props = this.props;
:[hole]
}
}`),
// this command is applying all the replacments in original files
CW.flushWith(CW.flushInPlace)
)
}
main();
- Run script
node script.js
# or if you want to see progress bar
PROGRESS=1 node script.js
Documentation
Plz read this before you start to use comby-wrapper:
- official comby docs https://comby.dev/docs/overview
- official rambdax docs https://github.com/selfrefactor/rambdax#api
- examples folder for query and replace example