Files
Neil 411843f633 fix(ci): cache the vendored addon where node-gyp actually writes it (#20445)
The workspace link means pnpm never creates a .pnpm/@orca+windows-registry@*
entry, so all four native-cache blocks globbed a path that cannot exist and
the addon was recompiled on every Windows job.

Also hardens the addon itself: RegEnumValueW reports a byte count and the
registry does not enforce whole WCHARs for string types, so an odd count let
Napi's auto-length scan run past the value; and a value named __proto__ would
reassign the result object's prototype instead of becoming an entry.
2026-09-12 20:45:42 -07:00

38 lines
932 B
JavaScript

'use strict'
// Why lazy: non-Windows installs never build the addon, so requiring it at module load would
// break any import of this package on macOS/Linux — including test collection.
let addon = null
function getAddon() {
if (!addon) {
addon = require('./build/Release/orca_windows_registry.node')
}
return addon
}
const HK = {
CR: 0x80000000,
CU: 0x80000001,
LM: 0x80000002,
U: 0x80000003,
PD: 0x80000004,
CC: 0x80000005,
DD: 0x80000006
}
function getRegistryKey(root, path) {
const values = getAddon().getKey(root, path)
if (!values) {
return null
}
// Null-prototype: a value literally named __proto__ would otherwise reassign the prototype
// instead of becoming an entry, and silently break the keyed-value contract.
const byName = Object.create(null)
for (const value of values) {
byName[value.name] = value
}
return byName
}
module.exports = { HK, getRegistryKey }