0

I found this snippet of code https://gist.github.com/wrboyce/786460

#!/usr/bin/zsh COMPRESSOR=$(whence -p yui-compressor) [ -z $COMPRESSOR ] && exit 0; function _compress { local fname=$1:t local dest_path=$1:h local min_fname="$dest_path/${fname:r}.min.${fname:e}" $COMPRESSOR $1 > $min_fname git add $min_fname } for file in $(find . -regextype posix-extended -iregex '.+\.(css|js)$' -and -not -iregex '.+\.min\.(css|js)$'); _compress $file 

On my osx machine it says:

.git/hooks/pre-commit: line 2: whence: command not found

I believe this is for linux only? Could anyone help to do this on a mac? I want to minify my css and javascript before it is sent to the remote production server.

1 Answer 1

1

Yes it's for Linux only:

The whence command is a Korn Shell feature that tells how a name would be interpreted by the shell: it detects commands and aliases, and searches your path.

Try this:

#!/usr/bin/zsh COMPRESSOR=$(which yui-compressor) [ -z $COMPRESSOR ] && exit 0; function _compress { local fname=$1:t local dest_path=$1:h local min_fname="$dest_path/${fname:r}.min.${fname:e}" $COMPRESSOR $1 > $min_fname git add $min_fname } for file in $(find . -regextype posix-extended -iregex '.+\.(css|js)$' -and -not -iregex '.+\.min\.(css|js)$'); _compress $file 
Sign up to request clarification or add additional context in comments.

1 Comment

Strange, whence is also a zsh builtin. I actually wrote the original gist on my OSX machine.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.