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}

参考


Related #js

AWS SESの受信メールを暗号化してs3に保存しLambdaで読み込む

jsの場合、複合処理を独自実装する必要がある

Next.jsのPreview Mode時はAnalyticsを無効化する

cookieの__next_preview_dataキーで判定

Next.js 11

手軽にアップグレードできた

VSCode Remoteで新規ファイルを作った際にTypescriptのPathが認識されない問題

「Ctrl + Shift + P」でコマンドパレットを開いて「Reload Window」を実行