show-required.sh 546 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. # Part of Zombie Navigator
  3. # Copyright © 2015 Zombie Navigator Developers
  4. dir="`dirname "$0"`"/..
  5. cd "$dir"
  6. printf "\n"
  7. [ "$1" ] && {
  8. find src/ -name '*.js' -exec sh -c \
  9. "printf '%s: \n' "'"$1"'" ; grep 'require(' "'"$1"'" | sed 's/^.*require(\([^)]*\)).*$/\1/' | sort | uniq | grep --color -- "'"$2"'" && printf '\n'" -- {} "$1" \;
  10. :;} || {
  11. find src/ -name '*.js' -exec sh -c \
  12. "printf '%s: \n\n' "'"$1"'" ; grep 'require(' "'"$1"'" | sed 's/^.*require(\([^)]*\)).*$/\1/' | sort | uniq" -- {} \;
  13. }
  14. # vim: ts=4 noet ai