-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A Node API to catch deps installation prompts and handle it on the user's own #4864
Comments
I think this auto-install feature is provided from https://github.com/antfu/install-pkg, so it might be better to ask for bit cli support there? vitest/packages/vitest/src/node/pkg.ts Line 42 in 70e8a38
But, It might be still nice for Vitest to provide a way to opt-out of this auto-install via environment variable or something since currently this can be skipped only on CI or non-TTY stdout. vitest/packages/vitest/src/node/pkg.ts Lines 27 to 32 in 70e8a38
|
It would be nice to provide both options - disabling prompt and providing a way to install a package via a custom method so users of Bit also had a nice experience of auto installation. |
Maybe it's too dirty or it doesn't even work, but it just came to my mind. Would it be a viable "API" to control auto installation by something like // somewhere in the current `ensurePackageInstalled` (packages/vitest/src/node/pkg.ts)
// ...
if (process.env.VITEST_INSTALL_PKG === "false") {
return false;
}
if (process.env.VITEST_INSTALL_PKG) {
// VITEST_INSTALL_PKG should point to import-able js module with { default: () => Promise<void> }
// (probably it needs to be a full path since certain node_modules structure might not be visible from vitest package?)
const customInstallPkg = await import(process.env.VITEST_INSTALL_PKG);
await customInstallPkg.default(dependency)
return true;
}
// otherwise fallback to current `import("@antfu/install-pkg")`
// ... |
I would prefer updating |
Clear and concise description of the problem
This issue is from discussion: #4772 (comment)
The background is we are integrating Vitest in Node APIs into Bit workflow. However, Bit CLI doesn't use npm/yarn/pnpm to install dependencies directly. Instead we have
bit install
.In some cases, Vitest will prompt in terminal asking for installing dependencies like vitest ui, vitest coverage, jsdom etc. Then the logic would be out of control from Bit CLI.
Suggested solution
It would be great if we can catch them by a Node.js API and hand it over to
bit install
.The new API could be an API, an option, or any kinds of event handlers which can be fired when any dependency is missing and let user decides whether to install it by Vitest or leave the job to user.
Pseudo code:
Alternative
Just provide an option to fail the tests when any external deps not found.
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: