From 8e57dfb70da74ebb1940c54aed8b732ccba95f54 Mon Sep 17 00:00:00 2001 From: Adam Lynch Date: Wed, 12 Oct 2022 16:24:24 +0100 Subject: [PATCH] Don't call chrome.management.getSelf if it doesn't exist --- hot-reload.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/hot-reload.js b/hot-reload.js index 7183886..f6f9917 100644 --- a/hot-reload.js +++ b/hot-reload.js @@ -24,13 +24,16 @@ const watchChanges = (dir, lastTimestamp) => { }) } -chrome.management.getSelf (self => { - if (self.installType === 'development') { - chrome.runtime.getPackageDirectoryEntry (dir => watchChanges (dir)) - chrome.tabs.query ({ active: true, lastFocusedWindow: true }, tabs => { // NB: see https://github.com/xpl/crx-hotreload/issues/5 - if (tabs[0]) { - chrome.tabs.reload (tabs[0].id) - } - }) - } -}) +// This is not supported in Safari +if (chrome.management && chrome.management.getSelf) { + chrome.management.getSelf (self => { + if (self.installType === 'development') { + chrome.runtime.getPackageDirectoryEntry (dir => watchChanges (dir)) + chrome.tabs.query ({ active: true, lastFocusedWindow: true }, tabs => { // NB: see https://github.com/xpl/crx-hotreload/issues/5 + if (tabs[0]) { + chrome.tabs.reload (tabs[0].id) + } + }) + } + }) +}