Skip to content

Instantly share code, notes, and snippets.

@scriptype
Last active March 23, 2017 20:52
Show Gist options
  • Save scriptype/d204e25ce58a90688d9531c77929f57f to your computer and use it in GitHub Desktop.
Save scriptype/d204e25ce58a90688d9531c77929f57f to your computer and use it in GitHub Desktop.
Find module names where the given term is being `import`ed
# Needs useof.sh to work (https://gist.github.com/scriptype/96c2cb131ddfc9080128a52d5e633c58)
function importof {
if [[ -n $1 ]]
then
if [[ -n $2 ]]
then
local dir=$2;
else
local dir=".";
fi
useof "import\s\+\?\({\s\+\)$1\?\(.\+\)\?\(\s\+}\s\+\)from" $dir
else
echo 'Usage: importof <term> <dir>[optional]'
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment