Files
orca/config/scripts/native-build/node-addons/native-build-entry-probe.cjs
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

55 lines
1.8 KiB
JavaScript

'use strict'
// Probe addon load in fresh runtime process: failed native load can poison process. Usage: <runtime> this.cjs <module> <dir>.
const { accessSync, constants, existsSync } = require('node:fs')
const { join } = require('node:path')
const { assertNodePtyJobOwnership } = require('./node-pty-job-ownership.cjs')
const {
assertWindowsProcessTreeCreationTime
} = require('../windows/windows-process-tree-creation-time.cjs')
const { nodePtyNativeModuleName } = require('./native-build-entry.cjs')
const NODE_PTY_CONPTY_RUNTIME_FILES = ['conpty.dll', 'OpenConsole.exe']
function probeNativeBuildDir(moduleName, dir) {
if (moduleName === 'node-pty') {
const nativeName = nodePtyNativeModuleName()
const addonPath = join(dir, `${nativeName}.node`)
const native = { dir, module: require(addonPath) }
assertNodePtyJobOwnership({ nativeName, native, addonPath })
if (process.platform === 'darwin') {
accessSync(join(dir, 'spawn-helper'), constants.X_OK)
}
if (nativeName === 'conpty') {
for (const filename of NODE_PTY_CONPTY_RUNTIME_FILES) {
if (!existsSync(join(dir, 'conpty', filename))) {
throw new Error(
`node-pty ConPTY runtime file is missing: ${join(dir, 'conpty', filename)}`
)
}
}
}
return
}
if (moduleName === '@vscode/windows-process-tree') {
assertWindowsProcessTreeCreationTime({
module: require(join(dir, 'windows_process_tree.node'))
})
return
}
throw new Error(`no probe for ${moduleName}`)
}
if (require.main === module) {
const [moduleName, dir] = process.argv.slice(2)
try {
probeNativeBuildDir(moduleName, dir)
} catch (error) {
console.error(`${moduleName}: ${error instanceof Error ? error.message : String(error)}`)
process.exit(1)
}
}
module.exports = { probeNativeBuildDir }