detect-package-manager icon indicating copy to clipboard operation
detect-package-manager copied to clipboard

feat: migrate to smaller exec package

Open 43081j opened this issue 1 year ago • 3 comments

Migrates from execa to tinyexec, a much lighter alternative.

Also changes two of the async functions to use async/await instead of then chaining.

43081j avatar Aug 19 '24 14:08 43081j

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

View full report↗︎

socket-security[bot] avatar Aug 19 '24 14:08 socket-security[bot]

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;
}

benmccann avatar Aug 20 '24 16:08 benmccann

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

43081j avatar Aug 20 '24 21:08 43081j