derhuerst/util-inspect-cli

add support for (static) JS input

Open

#1 aperta il 26 gen 2021

Vedi su GitHub
 (0 commenti) (0 reazioni) (0 assegnatari)JavaScript (0 fork)github user discovery
enhancementgood first issue

Metriche repository

Star
 (1 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

It would be cool to be able to pipe JS expressions into util-inspect:

echo '{foo: [{bar: 'baz'}]}' | util-inspect --js
# { foo: [ { bar: 'baz' } ] }

It shouldn't evaluate the JS expression though, as e.g. curl | util-inspect might easily get abused then, but it could

  1. parse the JS using acorn
  2. check if its static (only ArrayExpression, ObjectExpression, Property, Identifier, Literal)
  3. evaluate it
  4. inspect it as with JSON input

Guida contributor