detect-package-manager
detect-package-manager copied to clipboard
feat: migrate to smaller exec package
Migrates from execa to tinyexec, a much lighter alternative.
Also changes two of the async functions to use async/await instead of then chaining.
New dependencies detected. Learn more about Socket for GitHub ↗︎
| Package | New capabilities | Transitives | Size | Publisher |
|---|---|---|---|---|
| npm/[email protected] | environment, shell | 0 |
42.6 kB | 43081j |
I don't think that either execa or tinyexec are needed. Here's what we do in create-svelte:
/**
* Supports npm, pnpm, Yarn, cnpm, bun and any other package manager that sets the
* npm_config_user_agent env variable.
* Thanks to https://github.com/zkochan/packages/tree/main/which-pm-runs for this code!
*/
function get_package_manager() {
if (!process.env.npm_config_user_agent) {
return undefined;
}
const user_agent = process.env.npm_config_user_agent;
const pm_spec = user_agent.split(' ')[0];
const separator_pos = pm_spec.lastIndexOf('/');
const name = pm_spec.substring(0, separator_pos);
return name === 'npminstall' ? 'cnpm' : name;
}
happy to change it to that if we can get agreement from @egoist
seems to make sense to me if they all set that var