mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-20 08:50:46 +08:00
Harden public package installation and release validation
This commit is contained in:
parent
9271494b37
commit
9b2166e5b6
41 changed files with 994 additions and 363 deletions
17
scripts/npm-cli.mjs
Normal file
17
scripts/npm-cli.mjs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/** Resolve the npm bundled with Node instead of an unrelated global npm shim. */
|
||||
import assert from 'node:assert/strict'
|
||||
import { existsSync } from 'node:fs'
|
||||
import { dirname, join, resolve } from 'node:path'
|
||||
import { spawnSync } from 'node:child_process'
|
||||
|
||||
export function npmRuntime() {
|
||||
const node = process.versions.bun
|
||||
? spawnSync('node', ['-p', 'process.execPath'], { encoding: 'utf8', windowsHide: true }).stdout.trim()
|
||||
: process.execPath
|
||||
const npm = [process.env.NETXOPS_NPM_CLI,
|
||||
join(dirname(node), 'node_modules/npm/bin/npm-cli.js'),
|
||||
resolve(dirname(node), '../lib/node_modules/npm/bin/npm-cli.js'),
|
||||
].filter(Boolean).find(existsSync)
|
||||
assert.ok(npm, 'Node.js must include npm to build and test the public installation package.')
|
||||
return { node, npm }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue