aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/node-gyp/lib/util.js
diff options
context:
space:
mode:
authorpack <pack@packgekko.xyz>2026-08-09 10:54:08 +0000
committerpack <pack@packgekko.xyz>2026-08-09 10:54:08 +0000
commitd3adc16a08d95d6e331de55d7d3bf05a66a874a8 (patch)
treea2dabd199501e67c547c2ce79e1374ca3aa55443 /node_modules/node-gyp/lib/util.js
parent55a4f1fc869e41aca748c63d3018f0448b1606e0 (diff)
downloadcrud-d3adc16a08d95d6e331de55d7d3bf05a66a874a8.tar.gz
stop tracking node_modules/
Diffstat (limited to '')
-rw-r--r--node_modules/node-gyp/lib/util.js81
1 files changed, 0 insertions, 81 deletions
diff --git a/node_modules/node-gyp/lib/util.js b/node_modules/node-gyp/lib/util.js
deleted file mode 100644
index 3f6aeeb..0000000
--- a/node_modules/node-gyp/lib/util.js
+++ /dev/null
@@ -1,81 +0,0 @@
-'use strict'
-
-const cp = require('child_process')
-const path = require('path')
-const { openSync, closeSync } = require('graceful-fs')
-const log = require('./log')
-
-const execFile = async (...args) => new Promise((resolve) => {
- const child = cp.execFile(...args, (...a) => resolve(a))
- child.stdin.end()
-})
-
-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 [err, stdout, stderr] = await execFile(reg, regArgs, { encoding: 'utf8' })
-
- 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]
-}
-
-async function regSearchKeys (keys, value, addOpts) {
- for (const key of keys) {
- try {
- return await regGetValue(key, value, addOpts)
- } catch {
- continue
- }
- }
-}
-
-/**
- * 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 = {
- execFile,
- regGetValue,
- regSearchKeys,
- findAccessibleSync
-}