( info: UpdateObject | null, settings: LoadedSettings, projectRoot: string, isSandboxEnabled: boolean, spawnFn: typeof spawn = spawnWrapper, )
| 65 | } |
| 66 | |
| 67 | export function handleAutoUpdate( |
| 68 | info: UpdateObject | null, |
| 69 | settings: LoadedSettings, |
| 70 | projectRoot: string, |
| 71 | isSandboxEnabled: boolean, |
| 72 | spawnFn: typeof spawn = spawnWrapper, |
| 73 | ) { |
| 74 | if (!info) { |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | if (isSandboxEnabled) { |
| 79 | updateEventEmitter.emit('update-info', { |
| 80 | message: `${info.message}\nAutomatic update is not available in sandbox mode.`, |
| 81 | }); |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | if (!settings.merged.general.enableAutoUpdateNotification) { |
| 86 | return; |
| 87 | } |
| 88 | |
| 89 | const installationInfo = getInstallationInfo( |
| 90 | projectRoot, |
| 91 | settings.merged.general.enableAutoUpdate, |
| 92 | ); |
| 93 | |
| 94 | if ( |
| 95 | [ |
| 96 | PackageManager.NPX, |
| 97 | PackageManager.PNPX, |
| 98 | PackageManager.BUNX, |
| 99 | PackageManager.BINARY, |
| 100 | ].includes(installationInfo.packageManager) |
| 101 | ) { |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | let combinedMessage = info.message; |
| 106 | if (installationInfo.updateMessage) { |
| 107 | combinedMessage += `\n${installationInfo.updateMessage}`; |
| 108 | } |
| 109 | |
| 110 | if ( |
| 111 | !installationInfo.updateCommand || |
| 112 | !settings.merged.general.enableAutoUpdate |
| 113 | ) { |
| 114 | updateEventEmitter.emit('update-received', { |
| 115 | ...info, |
| 116 | message: combinedMessage, |
| 117 | isUpdating: false, |
| 118 | }); |
| 119 | return; |
| 120 | } |
| 121 | updateEventEmitter.emit('update-received', { |
| 122 | ...info, |
| 123 | message: combinedMessage, |
| 124 | isUpdating: true, |
no test coverage detected