fix(qmd): resolve hoisted dependencies from package context
CI / CI configuration security checks (push) Successful in 3s
CI / Capabilities and shell quality (push) Successful in 15s
CI / Python tests and compilation (push) Successful in 23s
CI / QMD unit tests (push) Failing after 11s
CI / Build and inspect generated packages (push) Successful in 17s
CI / PowerShell tests on Ubuntu (push) Successful in 1m2s
CI / Installed client configuration smoke tests (push) Successful in 1m7s
CI / Bash integration and installation guards (push) Successful in 1m17s

This commit is contained in:
Julian lechner committed 2026-10-08 15:25:33 +02:00
1 parent 88f7c9984b
commit 7f441d388d
5 files changed
+40 -14

No files matched your search

+7
View File
@@ -3,6 +3,7 @@ import { createHash } from 'node:crypto';
import { execFileSync } from 'node:child_process';
import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
import { homedir } from 'node:os';
import { createRequire } from 'node:module';
import { dirname, join, resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
@@ -82,6 +83,12 @@ export function importQmd(subpath = join('dist', 'index.js')) {
return import(pathToFileURL(join(qmdPackageDir(), subpath)).href);
}
// Resolve from QMD so both nested and hoisted dependency installations work.
export function importQmdDependency(name) {
const require = createRequire(pathToFileURL(join(qmdPackageDir(), 'package.json')));
return import(pathToFileURL(require.resolve(name)).href);
}
// Runs the QMD CLI through node without a shell, so free-text arguments are never re-parsed.
export function runQmdCli(args, options = {}) {
return execFileSync(process.execPath, [join(qmdPackageDir(), 'dist', 'cli', 'qmd.js'), ...args], { encoding: 'utf8', maxBuffer: 16 * 1024 * 1024, ...options });