Skip to content

Instantly share code, notes, and snippets.

@mohayonao
Last active May 23, 2017 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohayonao/28ca88f64dddb575948c95a6dbd9a222 to your computer and use it in GitHub Desktop.
Save mohayonao/28ca88f64dddb575948c95a6dbd9a222 to your computer and use it in GitHub Desktop.
#!/bin/sh
cmd=""
arg=$*
if [ -z "$cmd" ]; then
if [[ $1 =~ (^|\/)test\/.+\.js$ ]]; then
if [[ $(npm run) =~ ( test ) ]]; then
cmd="npm run test"
arg="-- $*"
fi
fi
fi
if [ -z "$cmd" ]; then
if [ -f "$(npm bin)/../../.babelrc" ]; then
if [ -f "$(npm bin)/babel-node" ]; then
cmd="$(npm bin)/babel-node"
elif [ -f "$(which babel-node)" ]; then
cmd="$(which babel-node)"
fi
fi
fi
if [ -z "$cmd" ]; then
cmd="node"
fi
$cmd $arg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment