将TODO注释显示为警告,但Pods文件夹除外 [英] Show TODO comments as warnings excluding the Pods folder

查看:66
本文介绍了将TODO注释显示为警告,但Pods文件夹除外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个脚本来显示我所有的 // TODO:注释,如下所示:

I have a script to show all my //TODO: comments which looks like this:

KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"

find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | 
  xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | 
  perl -p -e "s/($KEYWORDS)/ warning: \$1/"

我要排除我的 Pods 文件夹,因此我添加了 -not -path ./Pods/*\"

I want to exclude my Pods folder, therefore I have added -not -path "./Pods/*":

find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "./Pods/*" -print0 | 
  xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | 
  perl -p -e "s/($KEYWORDS)/ warning: \$1/"

这在我在终端上尝试时按预期工作(将 $ {SRCROOT} ),但是当它由Xcode运行时,它也会使用 Pods 文件夹。

This works as expected when I try it on the Terminal (replacing "${SRCROOT}" with "."), but when it is run by Xcode it uses the Pods folder as well.

如何

最终版本

在构建阶段脚本中排除该文件夹?工作:

This seems to work:

KEYWORDS="TODO:|FIXME:|\?\?\?:|\!\!\!:"
find "." \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "./Pods/*" -print0 | 
  xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | 
  perl -p -e "s/($KEYWORDS)/ warning: \$1/"


推荐答案

我将使用 find。并将构建脚本的工作目录设置为 $ {SRCROOT} 。这应该允许中的 -not -path ./Pods / * 查找

I would use find . and set the working directory of the build script to ${SRCROOT}. This should allow the . in -not -path "./Pods/*" to make sense to find.

这篇关于将TODO注释显示为警告,但Pods文件夹除外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆