'use strict' const log = require('npmlog') const execFile = require('child_process').execFile const path = require('path') 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) } } function regGetValue (key, value, addOpts, cb) { 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 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() } 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) }) } search() } module.exports = { logWithPrefix: logWithPrefix, regGetValue: regGetValue, regSearchKeys: regSearchKeys }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
Find-VisualStudio.cs | File | 7.75 KB | 0644 |
|
build.js | File | 5.38 KB | 0644 |
|
clean.js | File | 355 B | 0644 |
|
configure.js | File | 12.04 KB | 0644 |
|
find-node-directory.js | File | 2.32 KB | 0644 |
|
find-python.js | File | 10.88 KB | 0644 |
|
find-visualstudio.js | File | 13.53 KB | 0644 |
|
install.js | File | 14.01 KB | 0644 |
|
list.js | File | 641 B | 0644 |
|
node-gyp.js | File | 4.57 KB | 0644 |
|
process-release.js | File | 5.65 KB | 0644 |
|
proxy.js | File | 2.57 KB | 0644 |
|
rebuild.js | File | 314 B | 0644 |
|
remove.js | File | 1.28 KB | 0644 |
|
util.js | File | 1.87 KB | 0644 |
|