独立的 Shell 脚本工作正常,但是当使用 sh_binary 的 srcs 时它不起作用

问题描述

我的项目结构如下- PROJECT_STRUCTURE

现在 my_shbin.sh 如下 -

#!/bin/bash
find ../../ \( -name "*.java" -o -name "*.xml" -o -name "*.html" -o -name "*.js" -o -name "*.css" \) | grep -vE "/node_modules/|/target/|/dist/" >> temp-scan-files.txt

# scan project files for offensive terms
IFS=$'\n'
for file in $(cat temp-scan-files.txt); do
    grep -iF -f temp-scan-regex.txt $file >> its-scan-report.txt
done

这个脚本在单独调用时完全正常并提供所需的结果。但是当我在我的 BUILD 文件添加以下 sh_binary 时,我在 temp-scan-files.txt 文件中看不到任何内容,因此它的扫描报告中没有任何内容.txt 文件

sh_binary(
    name = "findFiles",srcs = ["src/test/resources/my_shbin.sh"],data = glob(["temp-scan-files.txt","temp-scan-regex.txt","its-scan-report.txt"]),)

我使用播放图标从 intellij 运行 sh_binary,并尝试使用 bazel run :findFiles 从终端运行它。没有显示错误,但我看不到 temp-scan-files.txt 中的数据。 关于这个问题的任何帮助。bazel 的文档非常局限,除了用例之外几乎没有任何信息。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)