@@ -5,8 +5,8 @@ import {outputDebug} from './output.js'
55import { zod } from './schema.js'
66import { AbortSilentError } from './error.js'
77import { isTruthy } from './context/utilities.js'
8- import { jsonOutputEnabled } from './environment.js'
98import { exec } from './system.js'
9+ import { jsonOutputEnabled } from './environment.js'
1010import { CLI_KIT_VERSION } from '../common/version.js'
1111import { NotificationKey , NotificationsKey , cacheRetrieve , cacheStore } from '../../private/node/conf-store.js'
1212import { fetch } from '@shopify/cli-kit/node/http'
@@ -55,7 +55,7 @@ export async function showNotificationsIfNeeded(
5555 environment : NodeJS . ProcessEnv = process . env ,
5656) : Promise < void > {
5757 try {
58- if ( skipNotifications ( environment ) ) return
58+ if ( skipNotifications ( environment ) || jsonOutputEnabled ( environment ) ) return
5959
6060 const notifications = await getNotifications ( )
6161 const commandId = getCurrentCommandId ( )
@@ -74,8 +74,8 @@ export async function showNotificationsIfNeeded(
7474 }
7575}
7676
77- function skipNotifications ( environment : NodeJS . ProcessEnv ) : boolean {
78- return isTruthy ( environment . CI ) || isTruthy ( environment . SHOPIFY_UNIT_TEST ) || jsonOutputEnabled ( environment )
77+ function skipNotifications ( environment : NodeJS . ProcessEnv = process . env ) : boolean {
78+ return isTruthy ( environment . CI ) || isTruthy ( environment . SHOPIFY_UNIT_TEST )
7979}
8080
8181/**
@@ -152,8 +152,15 @@ async function cacheNotifications(notifications: string): Promise<void> {
152152 *
153153 * @param currentCommand - The current Shopify command being run.
154154 * @param argv - The arguments passed to the current process.
155+ * @param environment - Process environment variables.
155156 */
156- export function fetchNotificationsInBackground ( currentCommand : string , argv = process . argv ) : void {
157+ export function fetchNotificationsInBackground (
158+ currentCommand : string ,
159+ argv = process . argv ,
160+ environment : NodeJS . ProcessEnv = process . env ,
161+ ) : void {
162+ if ( skipNotifications ( environment ) ) return
163+
157164 let command = 'shopify'
158165 const args = [ 'notifications' , 'list' ]
159166 // Run the Shopify command the same way as the current execution when it's not the global installation
0 commit comments