fix(runtime): stabilize Windows preparation and smoke checks
This commit is contained in:
1 parent
60438fc6a2
commit
e68478f1a4
2 files changed
+18
-5
No files matched your search
@@ -17,17 +17,17 @@ try {
|
||||
npm_config_userconfig: path.join(temp, 'npmrc'), npm_config_globalconfig: path.join(temp, 'npm-globalrc'),
|
||||
npm_config_cache: path.join(temp, 'npm-cache'), npm_config_prefix: path.join(temp, 'npm-prefix'),
|
||||
PYTHONUSERBASE: path.join(temp, 'python-user'), PIP_CACHE_DIR: path.join(temp, 'pip-cache'),
|
||||
PYTHONNOUSERSITE: '1', GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: path.join(temp, 'gitconfig'),
|
||||
PYTHONNOUSERSITE: '1', PYTHONDONTWRITEBYTECODE: '1', GIT_CONFIG_NOSYSTEM: '1', GIT_CONFIG_GLOBAL: path.join(temp, 'gitconfig'),
|
||||
PATH: [path.join(root, 'node'), path.join(root, 'python'), path.join(root, 'git/cmd'), path.join(root, 'git/bin'), path.join(process.env.SystemRoot || 'C:\\Windows', 'System32')].join(';') }
|
||||
const run = (exe, args) => {
|
||||
const r = spawnSync(exe, args, { cwd: temp, env, encoding: 'utf8', timeout: 60_000, windowsHide: true })
|
||||
const run = (exe, args, options = {}) => {
|
||||
const r = spawnSync(exe, args, { cwd: temp, env, encoding: 'utf8', timeout: 60_000, windowsHide: true, ...options })
|
||||
if (r.error || r.status !== 0) throw new Error(`${exe} ${args.join(' ')} failed: ${r.error || r.stderr || r.stdout}`)
|
||||
console.log(r.stdout.trim())
|
||||
}
|
||||
const node = path.join(root, 'node/node.exe'), python = path.join(root, 'python/python.exe')
|
||||
run(node, ['--version'])
|
||||
// Explicit cmd.exe, fixed arguments only; downloaded npm/npx scripts never use shell interpolation from user input.
|
||||
for (const command of ['npm', 'npx']) run(process.env.ComSpec || 'cmd.exe', ['/d', '/s', '/c', `""${path.join(root, `node/${command}.cmd`)}" --version"`])
|
||||
for (const command of ['npm', 'npx']) run(process.env.ComSpec || 'cmd.exe', ['/d', '/s', '/c', `""${path.join(root, `node/${command}.cmd`)}" --version"`], { windowsVerbatimArguments: true })
|
||||
run(python, ['--version']); run(python, ['-m', 'pip', '--version'])
|
||||
run(python, ['-m', 'venv', path.join(temp, 'venv')])
|
||||
run(path.join(temp, 'venv/Scripts/python.exe'), ['-m', 'pip', '--version'])
|
||||
|
||||
Reference in new issue
Block a user