yarn run実行時の不要なログを抑制する
Sentryで新しいリリースバージョンを作成する際に、sentry-cliで↓のようにVERSIONを生成するようにしたが正しく設定されない現象が起きた。
VERSION=`yarn run sentry-cli releases propose-version`
yarn run sentry-cli releases new ${VERSION}
echoでVERSIONの中身を確認してみると、↓のようにyarn runのログが含まれてしまっていた。
echo $VERSION
yarn run v1.21.1
sentry-cli releases propose-version
xxxxx
Done in 1.00s.
yarn runにはログを抑制する silent
オプションが用意されているのでこれを利用する。
yarn run --help | grep silent
-s, --silent skip Yarn console logs, other types of logs (script output) will be printed
さきほどのコマンドに silent
オプションを付与し、正しくVERSION環境変数が設定されるようになった。
VERSION=`yarn run --silent sentry-cli releases propose-version`
# => xxxxx
yarn run sentry-cli releases new ${VERSION}