[Registry] Move installProtocol to util, minor source cleanup
This commit is contained in:
parent
f1ab5b0d91
commit
82c23cf845
2 changed files with 10 additions and 11 deletions
|
@ -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) => {
|
exports.performFirstRunTasks = (updater) => {
|
||||||
log('FirstRun', 'Perform');
|
log('FirstRun', 'Perform');
|
||||||
|
|
||||||
|
@ -66,7 +61,7 @@ exports.performFirstRunTasks = (updater) => {
|
||||||
log('FirstRun', 'Error updating shortcuts', e);
|
log('FirstRun', 'Error updating shortcuts', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
installProtocol(Constants.APP_PROTOCOL, () => {
|
registry.installProtocol(Constants.APP_PROTOCOL, () => {
|
||||||
if (!shortcutSuccess) return;
|
if (!shortcutSuccess) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -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 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 = '';
|
let process, stdout = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -21,17 +21,21 @@ const spawn = (args, callback = (() => {})) => {
|
||||||
process.on('exit', (code, signal) => callback(code !== 0 ? new Error('Spawn: ' + signal ?? code) : null, stdout));
|
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();
|
const args = queue.shift();
|
||||||
if (!args) return callback();
|
if (!args) return callback();
|
||||||
|
|
||||||
args.unshift('add');
|
args = [ 'add', ...args, '/f' ];
|
||||||
args.push('/f');
|
|
||||||
|
|
||||||
return spawn(args, () => add(queue, callback));
|
return spawn(args, () => add(queue, callback));
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
spawn,
|
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);
|
||||||
|
}
|
||||||
};
|
};
|
Loading…
Reference in a new issue