首页 > 其他 > 详细

给源代码自动加 license 头部

时间:2017-08-08 13:14:55      阅读:283      评论:0      收藏:0      [点我收藏+]
function filtCodeFile()
{
    filename="$1"
    filepath="$2/$1"
    blackList="Pods"
    if [[ $filepath =~ $blackList ]]; then
        return 1
    fi
    if [ "${filename##*.}" = "h" -o "${filename##*.}" == "m" ]; then
        if [ ! -z "`grep "MIT License" $filepath`" ]; then
            echo "[$filepath] aleady has license describe."
            #test
        else
            echo "/* " > ./copy_license_file.txt
            cat "./LICENSE" >> ./copy_license_file.txt
            echo " */" >> ./copy_license_file.txt
            cat "$filepath" >> ./copy_license_file.txt
            mv ./copy_license_file.txt $filepath
            echo "[$filepath] add license finish!"
        fi
    fi
}

function traversingFiles()
{
    #1st param, the dir name
    for file in `ls $1`;
    do
        if [ -d "$1/$file" ]; then
            #filtCodeFile $file $1
            traversingFiles "$1/$file" "$1"
        else
            filtCodeFile $file $1
        fi
    done
    rm -f ./copy_license_file.txt
}

traversingFiles "."

 

给源代码自动加 license 头部

原文:http://www.cnblogs.com/AkQuan/p/7306209.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!