【问题标题】:Problem redirecting stdout in Node 16's package.json在节点 16 的 package.json 中重定向标准输出的问题
【发布时间】:2022-11-10 05:29:07
【问题描述】:

我的 package.json 的脚本部分中有三个脚本目标:

"schema:generate": "mkdir -p ./dist && typescript-json-schema tsconfig.json --tsNodeRegister --required --strictNullChecks --noExtraProps --refs --aliasRefs WireMessage >dist/tmpschema",
"schema:replace": "cat dist/tmpschema | sed 's:#/definitions/:#/components/schemas/WireMessage/definitions/:g' >dist/swagger.schema.json",
"schema:messages": "cp dist/tmpschema dist/messages.schema.json",
"schema": "yarn run schema:generate && yarn run schema:replace && yarn run schema:messages",

然而,yarn run schema 使得dist/swagger.schema.json 不断地只得到dist/tmpschema 的一半内容。为什么?

这有效,替换

 >dist/swagger.schema.json

和

 | tee dist/swagger.schema.json >/dev/null

该文件正好是 2^15 个字节,其中 32 768 个。哇。

【问题讨论】:

    标签: node.js stdout


    【解决方案1】:

    Node 有一个 bug,因此如果重定向的输出大于 short,它会被截断。

    而是使用命令tee

    【讨论】:

      猜你喜欢
      • 2011-10-05
      • 1970-01-01
      • 2011-02-26
      • 2013-05-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-11
      • 2014-01-20
      相关资源
      最近更新 更多