Skip to content

Instantly share code, notes, and snippets.

@msikma
Last active September 25, 2018 23:32
Show Gist options
  • Save msikma/a5ee8252c3629fb9cb0f38db69bc9d90 to your computer and use it in GitHub Desktop.
Save msikma/a5ee8252c3629fb9cb0f38db69bc9d90 to your computer and use it in GitHub Desktop.
function check_node_project \
--description 'Display project info if we changed to a Node project directory' \
--on-variable dirprev
# Don't display project info if:
status --is-command-substitution; # this is command substitution \
or not test -f ./package.json; # there's no package.json \
or [ (count $dirprev) -lt 3 ]; # we've just opened a new Terminal session \
or [ (count (string split $PWD $dirprev[-1])) -eq 2 ]; # we came from a lower directory in the hierarchy \
and return
# Displays project name, version, and a list of bin files and npm scripts.
node-project.js
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment