-
-
Save okunokentaro/d3cb4e5ae8a22d61cd5b7a8c3d43073a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
if [ -z "$1" ]; then | |
exit 1 | |
fi | |
BASEDIR="." | |
EXTENSIONS="ts,tsx" | |
TSCONFIG="./tsconfig.json" | |
RELATIVE_TARGET=${1#./} | |
PATTERN=$({ | |
npx madge "${RELATIVE_TARGET}" \ | |
--extensions ${EXTENSIONS} \ | |
--ts-config ${TSCONFIG} \ | |
--basedir "${BASEDIR}" \ | |
| sed '/^Processed/d;/^$/d' | |
npx madge --depends "${RELATIVE_TARGET}" \ | |
--extensions ${EXTENSIONS} \ | |
--ts-config ${TSCONFIG} \ | |
--basedir "${BASEDIR}" \ | |
"${BASEDIR}" \ | |
| sed '/^Processed/d;/^$/d' | |
} | sed 's/[.[\*^$()+?{|]/\\&/g' | paste -sd'|' -) | |
if [ "$2" = "-l" ]; then | |
rg --files | rg "$PATTERN" | |
else | |
rg --files | rg "$PATTERN" | xargs rg "." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment