Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

Feature: support --inspect flags #68

Closed
paulirish opened this issue Jul 11, 2017 · 5 comments
Closed

Feature: support --inspect flags #68

paulirish opened this issue Jul 11, 2017 · 5 comments

Comments

@paulirish
Copy link

(Been using npx since 1.0.2. Love it.)

I often want to run node --inspect and node --inspect-brk on apps that I also like to run via npx. For example: I want to breakpoint debug a mocha test, or do a performance profile of eslint .

AFAIK, there isnt' a decent workaround, so I always go back to node --inspect-brk ./node_modules/eslint/bin/eslint.js . which is fine but obviously it'd be nice to avoid this.

Could we add --inspect-brk and --inspect as supported npx flags?

@zkat
Copy link
Owner

zkat commented Jul 11, 2017

@paulirish tapjs/tapjs#160 (comment) would mirroring this behavior be of enough use to you? It'd be nice to make sure there's a more general way of passing opts down to node. This would also only apply to actual execution operations, not when npx is internally doing npm operations.

@paulirish
Copy link
Author

so you're saying an API like this:

npx --node-arg=--inspect-brk eslint .

that's not as ideal but i guess it works. Though at that point i already have to freehand type such a long command, i'd rather just start with node --inspect-brk and then go back to tab completing the node_modules path. :/

so if you prefer that direction then i'll probably release a mini npx-inspect module that wraps around it for ease of use.

@zkat
Copy link
Owner

zkat commented Jul 12, 2017

@paulirish I spent some more time thinking about this and I really like the idea of just having a wrapper that hides the verbosity. This is the sort of thing that stuff like that or aliases are good for.

Plus, it means you can do $ npx npx-inspect eslint . 😂

There's one caveat to all this: If I add this option, I'm going to have to make npx crash out if it can't detect that the target is a node script. in general, this should be fine, but npx's detection of shebangs isn't really perfect right now. I imagine you're ok with an 80% solution and then we can fine-tune if/when running into stuff where npx can't tell if it's node.

@zkat
Copy link
Owner

zkat commented Jul 12, 2017

I've prototyped this over at #77.

@zkat zkat closed this as completed in #77 Jul 12, 2017
zkat added a commit that referenced this issue Jul 12, 2017
…inaries (#77)

* feat(node): add ability to inspect binaries when detected to be node scripts

Fixes: #68

* test: add tests for -n and --node-arg parsing

* feat(node-arg): allow space-separated arg strings
@zkat
Copy link
Owner

zkat commented Jul 12, 2017

This is available in npx@9.1.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants