MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / doCheckUpdate

Function doCheckUpdate

src/background/utils/update.js:80–109  ·  view source on GitHub ↗
(id, script, urls, opts)

Source from the content-addressed store, hash-verified

78});
79
80async function doCheckUpdate(id, script, urls, opts) {
81 let res;
82 let msgOk;
83 let msgErr;
84 try {
85 const { update } = await parseScript({
86 id,
87 code: await downloadUpdate(script, urls, opts),
88 bumpDate: true,
89 update: { [kChecking]: false },
90 ...opts,
91 });
92 msgOk = i18n('msgScriptUpdated', [getScriptName(update)]);
93 res = true;
94 } catch (update) {
95 msgErr = update.error
96 || !update[kChecking] && await fetchResources(script, opts);
97 if (process.env.DEBUG) console.error(update);
98 } finally {
99 if (canNotify(script) && (msgOk || msgErr)) {
100 res = {
101 script,
102 text: [msgOk, msgErr]::trueJoin('\n'),
103 err: !!msgErr,
104 };
105 }
106 delete processes[id];
107 }
108 return res;
109}
110
111async function downloadUpdate(script, urls, opts) {
112 let errorMessage;

Callers 1

CheckUpdateFunction · 0.85

Calls 5

parseScriptFunction · 0.90
getScriptNameFunction · 0.90
fetchResourcesFunction · 0.90
downloadUpdateFunction · 0.85
canNotifyFunction · 0.85

Tested by

no test coverage detected