'Problem redirecting stdout in Node 16's package.json

I have three script targets in my package.json's script section:

"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",

However, yarn run schema makes dist/swagger.schema.json constantly get only half the contents of dist/tmpschema. Why?

This works, replacing

 >dist/swagger.schema.json

with

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

The file is exactly 2^15 bytes, 32 768 of them. WTF.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source