update electron to v43

This commit is contained in:
olcxja 2026-07-09 22:38:33 +02:00
commit fb6c8b6ee9
5385 changed files with 513060 additions and 123058 deletions

View file

@ -1,64 +1,81 @@
'use strict'
const log = require('npmlog')
const execFile = require('child_process').execFile
const cp = require('child_process')
const path = require('path')
const { openSync, closeSync } = require('graceful-fs')
const log = require('./log')
function logWithPrefix (log, prefix) {
function setPrefix (logFunction) {
return (...args) => logFunction.apply(null, [ prefix, ...args ]) // eslint-disable-line
}
return {
silly: setPrefix(log.silly),
verbose: setPrefix(log.verbose),
info: setPrefix(log.info),
warn: setPrefix(log.warn),
error: setPrefix(log.error)
}
}
const execFile = async (...args) => new Promise((resolve) => {
const child = cp.execFile(...args, (...a) => resolve(a))
child.stdin.end()
})
function regGetValue (key, value, addOpts, cb) {
async function regGetValue (key, value, addOpts) {
const outReValue = value.replace(/\W/g, '.')
const outRe = new RegExp(`^\\s+${outReValue}\\s+REG_\\w+\\s+(\\S.*)$`, 'im')
const reg = path.join(process.env.SystemRoot, 'System32', 'reg.exe')
const regArgs = ['query', key, '/v', value].concat(addOpts)
log.silly('reg', 'running', reg, regArgs)
const child = execFile(reg, regArgs, { encoding: 'utf8' },
function (err, stdout, stderr) {
log.silly('reg', 'reg.exe stdout = %j', stdout)
if (err || stderr.trim() !== '') {
log.silly('reg', 'reg.exe err = %j', err && (err.stack || err))
log.silly('reg', 'reg.exe stderr = %j', stderr)
return cb(err, stderr)
}
const [err, stdout, stderr] = await execFile(reg, regArgs, { encoding: 'utf8' })
const result = outRe.exec(stdout)
if (!result) {
log.silly('reg', 'error parsing stdout')
return cb(new Error('Could not parse output of reg.exe'))
}
log.silly('reg', 'found: %j', result[1])
cb(null, result[1])
})
child.stdin.end()
log.silly('reg', 'reg.exe stdout = %j', stdout)
if (err || stderr.trim() !== '') {
log.silly('reg', 'reg.exe err = %j', err && (err.stack || err))
log.silly('reg', 'reg.exe stderr = %j', stderr)
if (err) {
throw err
}
throw new Error(stderr)
}
const result = outRe.exec(stdout)
if (!result) {
log.silly('reg', 'error parsing stdout')
throw new Error('Could not parse output of reg.exe')
}
log.silly('reg', 'found: %j', result[1])
return result[1]
}
function regSearchKeys (keys, value, addOpts, cb) {
var i = 0
const search = () => {
log.silly('reg-search', 'looking for %j in %j', value, keys[i])
regGetValue(keys[i], value, addOpts, (err, res) => {
++i
if (err && i < keys.length) { return search() }
cb(err, res)
})
async function regSearchKeys (keys, value, addOpts) {
for (const key of keys) {
try {
return await regGetValue(key, value, addOpts)
} catch {
continue
}
}
search()
}
/**
* Returns the first file or directory from an array of candidates that is
* readable by the current user, or undefined if none of the candidates are
* readable.
*/
function findAccessibleSync (logprefix, dir, candidates) {
for (let next = 0; next < candidates.length; next++) {
const candidate = path.resolve(dir, candidates[next])
let fd
try {
fd = openSync(candidate, 'r')
} catch (e) {
// this candidate was not found or not readable, do nothing
log.silly(logprefix, 'Could not open %s: %s', candidate, e.message)
continue
}
closeSync(fd)
log.silly(logprefix, 'Found readable %s', candidate)
return candidate
}
return undefined
}
module.exports = {
logWithPrefix: logWithPrefix,
regGetValue: regGetValue,
regSearchKeys: regSearchKeys
execFile,
regGetValue,
regSearchKeys,
findAccessibleSync
}