From 27c5d2a960e3c7b70a5732ac45775df45d66efae Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Mon, 4 Mar 2024 10:51:27 -0800 Subject: [PATCH] default to npm (#974) --- src/create.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/create.ts b/src/create.ts index 87248ff27..03400391b 100644 --- a/src/create.ts +++ b/src/create.ts @@ -80,7 +80,7 @@ export async function create(options = {}, effects: CreateEffects = defaultEffec {value: "yarn", label: "Yes, via yarn", hint: "recommended"}, {value: null, label: "No"} ], - initialValue: inferPackageManager() + initialValue: inferPackageManager("npm") }), initializeGit: () => clack.confirm({ @@ -205,12 +205,12 @@ async function recursiveCopyTemplate( } } -function inferPackageManager(): string | null { +function inferPackageManager(defaultValue: string | null): string | null { const userAgent = process.env["npm_config_user_agent"]; - if (!userAgent) return null; + if (!userAgent) return defaultValue; const pkgSpec = userAgent.split(" ")[0]!; // userAgent is non-empty, so this is always defined - if (!pkgSpec) return null; + if (!pkgSpec) return defaultValue; const [name, version] = pkgSpec.split("/"); - if (!name || !version) return null; + if (!name || !version) return defaultValue; return name; }