如何在鱼壳中加入两个NPM命令以避免纱线安装警告?

发布于 2025-02-07 05:12:31 字数 629 浏览 2 评论 0 原文

我想使用此

“ 2> >(grep -v警告1>& 2)

当我使用鱼壳时,我确实发现该命令必须成为 yarn install install 2> “>(grep -v警告1>& 2)要避免语法错误

,但是在我想运行 yarn运行post intstall -force 之后

,我的命令变成纱线安装2> “>(grep -v警告1>& 2)”&&纱线运行后插图 - force 似乎不起作用, YARN RUN POSTENSTALL -FORCE 并未真正运行。命令在纱线安装后立即完成完成。

有什么想法如何解决?

更新: 我还希望该脚本在Bash中运行,因为这不仅会在我的本地开发机上执行,而且还将在没有安装鱼壳的CD/CI上执行。

I want to ignore yarn errors using this method

yarn install 2> >(grep -v warning 1>&2)

As I am using fish shell I did figure out that this command has to become yarn install 2> ">(grep -v warning 1>&2)" to avoid a syntax error

However after one I want to run yarn run postinstall --force

So my command became yarn install 2> ">(grep -v warning 1>&2)" && yarn run postinstall --force however it seems does not work, yarn run postinstall --force does not really runs. Command finishes right afteryarn install finishes.

Any ideas how to fix?

UPDATE:
I also want that script to run in bash because this going to execute not just on my local dev machine but also on CD/CI that does not have fish-shell installed..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

雨的味道风的声音 2025-02-14 05:12:31

编辑:这个问题最初被标记为“鱼”,因此此答案假设您想使用鱼来运行脚本。

yarn install 2> >(grep -v warning 1>&2)

这有点笨拙。它将纱线安装的stderr管输入过程替换(>()语法,就像其<()表弟)。这将创建一个临时文件,然后将其连接到 grep -v 的stdin,然后将其输出重定向到stderr。效果是对STDER进行了过滤,并删除包含“警告”的任何线路。

的确,原因是它的bash中很尴尬,但不是stderr - 请参见我如何管道stderr,而不是stdout? - 这是 https://stackoverflow.com/ A/15936384/3150338

在FISH中,您只需用 2> | 将STDER置于stderr:

yarn install 2>| grep -v warning 1>&2

例如,

function printstuff
    echo error >&2
    echo warning >&2
    echo output
    echo warning but on stdout
end

printstuff 2>| grep -v warning 1>&2

请参阅stderr上的“错误”,以及“输出”和“警告,但在Stdout上”。

EDIT: The question was originally tagged as "fish", so this answer assumes you'd want to use fish to run the script.

yarn install 2> >(grep -v warning 1>&2)

This is a bit of an awkward idiom. It pipes the stderr of yarn install into a process substitution (the >() syntax, which is like the reverse of its <() cousin). This creates a temporary file that it will then connect to grep -v's stdin, which will then get its output redirected to stderr again. The effect is that stderr is filtered and any line containing "warning" is removed.

Really, the reason for this is that it is awkward in bash to pipe stderr but not stdout - see How can I pipe stderr, and not stdout? - this is https://stackoverflow.com/a/15936384/3150338.

In fish, you can just pipe stderr with 2>|:

yarn install 2>| grep -v warning 1>&2

See e.g.

function printstuff
    echo error >&2
    echo warning >&2
    echo output
    echo warning but on stdout
end

printstuff 2>| grep -v warning 1>&2

This will print "error" on stderr, and "output" and "warning but on stdout" on stdout.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文