diff --git a/src/firstRun/win32.js b/src/firstRun/win32.js index 96b84a1..d19728e 100644 --- a/src/firstRun/win32.js +++ b/src/firstRun/win32.js @@ -47,11 +47,6 @@ const updateShortcuts = (updater) => { } }; -const installProtocol = (protocol, callback) => { - const base = 'HKCU\\Software\\Classes\\' + protocol; - registry.add([[base, '/ve', '/d', `URL:${protocol} Protocol`], [base, '/v', 'URL Protocol'], [base + '\\DefaultIcon', '/ve', '/d', '"' + process.execPath + '",-1'], [base + '\\shell\\open\\command', '/ve', '/d', `"${process.execPath}" --url -- "%1"`]], callback); -}; - exports.performFirstRunTasks = (updater) => { log('FirstRun', 'Perform'); @@ -66,7 +61,7 @@ exports.performFirstRunTasks = (updater) => { log('FirstRun', 'Error updating shortcuts', e); } - installProtocol(Constants.APP_PROTOCOL, () => { + registry.installProtocol(Constants.APP_PROTOCOL, () => { if (!shortcutSuccess) return; try { diff --git a/src/utils/registry.js b/src/utils/registry.js index a74c581..0469098 100644 --- a/src/utils/registry.js +++ b/src/utils/registry.js @@ -5,7 +5,7 @@ const sr = process.env.SystemRoot; const regExe = join(sr || '', sr ? 'System32' : '', 'reg.exe'); // %SystemRoot%\System32\reg.exe OR reg.exe if SR is undefined -const spawn = (args, callback = (() => {})) => { +const spawn = (args, callback) => { let process, stdout = ''; try { @@ -21,17 +21,21 @@ const spawn = (args, callback = (() => {})) => { process.on('exit', (code, signal) => callback(code !== 0 ? new Error('Spawn: ' + signal ?? code) : null, stdout)); }; -const add = (queue, callback = (() => {})) => { +const add = (queue, callback) => { const args = queue.shift(); if (!args) return callback(); - args.unshift('add'); - args.push('/f'); + args = [ 'add', ...args, '/f' ]; return spawn(args, () => add(queue, callback)); }; module.exports = { spawn, - add + add, + + installProtocol: (protocol, callback) => { + const base = 'HKCU\\Software\\Classes\\' + protocol; + add([[base, '/ve', '/d', `URL:${protocol} Protocol`], [base, '/v', 'URL Protocol'], [base + '\\DefaultIcon', '/ve', '/d', `"${process.execPath}",-1`], [base + '\\shell\\open\\command', '/ve', '/d', `"${process.execPath}" --url -- "%1"`]], callback); + } }; \ No newline at end of file