Skip to content

Commit

Permalink
Merge branch 'main' into jc.javy-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles committed Nov 22, 2024
2 parents 32b75e2 + e923689 commit be45523
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/cli-kit/src/public/node/notifications-system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ describe('notifications-system', () => {
vi.mocked(cacheRetrieveOrRepopulate).mockResolvedValue(JSON.stringify({notifications}))

// When
await showNotificationsIfNeeded()
await showNotificationsIfNeeded(undefined, {SHOPIFY_UNIT_TEST: 'false'})

// Then
expect(renderInfo).toHaveBeenCalled()
Expand All @@ -346,7 +346,7 @@ describe('notifications-system', () => {
vi.mocked(cacheRetrieveOrRepopulate).mockResolvedValue(JSON.stringify({notifications}))

// When
await showNotificationsIfNeeded()
await showNotificationsIfNeeded(undefined, {SHOPIFY_UNIT_TEST: 'false'})

// Then
expect(renderWarning).toHaveBeenCalled()
Expand All @@ -358,7 +358,7 @@ describe('notifications-system', () => {
vi.mocked(cacheRetrieveOrRepopulate).mockResolvedValue(JSON.stringify({notifications}))

// When
await expect(showNotificationsIfNeeded()).rejects.toThrowError()
await expect(showNotificationsIfNeeded(undefined, {SHOPIFY_UNIT_TEST: 'false'})).rejects.toThrowError()

// Then
expect(renderError).toHaveBeenCalled()
Expand Down
6 changes: 5 additions & 1 deletion packages/cli-kit/src/public/node/notifications-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {getCurrentCommandId} from './global-context.js'
import {outputDebug} from './output.js'
import {zod} from './schema.js'
import {AbortSilentError} from './error.js'
import {isTruthy} from './context/utilities.js'
import {CLI_KIT_VERSION} from '../common/version.js'
import {
NotificationKey,
Expand Down Expand Up @@ -50,10 +51,13 @@ export type Notifications = zod.infer<typeof NotificationsSchema>
* Shows notifications to the user if they meet the criteria specified in the notifications.json file.
*
* @param currentSurfaces - The surfaces present in the current project (usually for app extensions).
* @param environment - Process environment variables.
* @returns - A promise that resolves when the notifications have been shown.
*/
export async function showNotificationsIfNeeded(currentSurfaces?: string[]): Promise<void> {
export async function showNotificationsIfNeeded(currentSurfaces?: string[], environment = process.env): Promise<void> {
try {
if (isTruthy(environment.CI) || isTruthy(environment.SHOPIFY_UNIT_TEST)) return

const notifications = await getNotifications()
const commandId = getCurrentCommandId()
const notificationsToShow = filterNotifications(notifications.notifications, commandId, currentSurfaces)
Expand Down

0 comments on commit be45523

Please sign in to comment.