我发现了这段代码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在我的osx机器上写着:
..git/钩子/预提交:第2行: whence:命令未找到
我相信这只适用于linux吗?有人能帮我在mac上做这件事吗?在将css和javascript发送到远程生产服务器之前,我希望将它们缩小。
发布于 2014-01-22 14:52:18
是的,它只适用于Linux:
whence命令是Korn特性,它告诉Shell将如何解释名称:它检测命令和别名,并搜索路径。
试试这个:
#!/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 $filehttps://stackoverflow.com/questions/21286002
复制相似问题