-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No instructions on debugging scripts #223
Comments
Agreed it would be nice to have better instructions, particularly around the use of I haven't tried it with jscodeshift specifically, but I think it's maybe more reliable to use the newer Another thing you can do is write the script in astexplorer (which is also really useful for getting immediate feedback and analyzing the AST) and drop into the debugger there. If you add a |
Thanks for the reply @alangpierce. I had use astexplorer but never to run a codeshift mod on it. That's really awesome, basically an IDE for this. I would say that debugging scripts locally is useful. For example, in my script I use some lodash functions and you can't do imports in astexplorer. All I would like is a little guidance as to where I should put the instructions and I'll get it done, using the --inspect flag instead of node-inspect (thanks for that by the way). Have a good day! |
👍 makes sense that it's still useful to run locally. As far as I know, the only real documentation (other than scattered blog posts) is the README, so maybe best to just put it there. The project maintainers may have more thoughts on docs organization, especially if you send a PR with something specific. The project hasn't been very active recently, though, so unfortunately it might take a while for PRs to be considered. |
Play much happier with vscode debugger tool; // launch.json
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"],
"port": 9229
}
]
} scripts: {
"dev": "node --inspect ./node_modules/jscodeshift/bin/jscodeshift.sh -t react-tsx.js ./samples --dry -p --run-in-band --extensions tsx --parser babylon"
} |
Would be great to have in the README 👍 |
Added to docs. Thanks for lighting the fire on this! |
While authoring a script, I struggled to find a way to debug it. I looked in the docs and didn't find anything. I would be happy to submit a PR with instructions, unless repo authors prefer to do it.
What worked for me:
node-inspector
jscodeshift
in my local repo as a dev dependency.debugger
statement in my scriptjscodeshift
via node with--debug-brk
arg and added--run-in-band
jscodeshift param. For example, I enterednode --debug-brk ./node_modules/jscodeshift/bin/jscodeshift.sh -t my-refactor-script.js --run-in-band
If you add a file pattern at the end, it works fine, which in the case of debugging is helpful when you want to test just one trouble file.
Here is a screenshot of it working
I did not test debugging
jscodeshift
installed vianpm -g
.For documentation, I'd like to see:
If you'd like me to put in the work, where should I put it? README, a wiki page, or somewhere else?
Thanks!
Steve
The text was updated successfully, but these errors were encountered: