Skip to content

Commit 5dd6f00

Browse files
author
strausr
committed
fix: add comments
1 parent 0325e1b commit 5dd6f00

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

cli.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { fileURLToPath } from 'url';
44
import { dirname, join } from 'path';
55
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
6-
import { execSync } from 'child_process';
6+
import { spawnSync } from 'child_process';
77
import inquirer from 'inquirer';
88
import chalk from 'chalk';
99
import fs from 'fs-extra';
@@ -29,6 +29,12 @@ function pkgFromUserAgent(userAgent) {
2929
return { name, version };
3030
}
3131

32+
/**
33+
* Resolve which client to run for install / dev.
34+
* Only npm, pnpm, yarn, and bun have explicit command mappings below; anything else
35+
* (missing env, exotic clients, parse quirks) falls back to npm as the safe default that
36+
* ships with Node and matches the install instructions most users expect.
37+
*/
3238
function detectPackageManager() {
3339
const pkg = pkgFromUserAgent(process.env.npm_config_user_agent);
3440
if (pkg && SUPPORTED_PACKAGE_MANAGERS.has(pkg.name)) {
@@ -56,8 +62,14 @@ function getRunDevCommand(packageManager) {
5662
}
5763

5864
function runPackageManagerCommand(args, cwd) {
59-
const quoted = args.map((arg) => (/[\s"'\\]/.test(arg) ? JSON.stringify(arg) : arg));
60-
execSync(quoted.join(' '), { stdio: 'inherit', cwd, shell: true });
65+
const [command, ...cmdArgs] = args;
66+
const result = spawnSync(command, cmdArgs, { stdio: 'inherit', cwd, shell: false });
67+
if (result.error) {
68+
throw result.error;
69+
}
70+
if (result.status !== 0) {
71+
throw new Error(`Command failed: ${args.join(' ')}`);
72+
}
6173
}
6274

6375
// Validate cloud name format
@@ -220,7 +232,7 @@ async function main() {
220232
if (packageManager && !SUPPORTED_PACKAGE_MANAGERS.has(packageManager)) {
221233
console.warn(
222234
chalk.yellow(
223-
`Unknown package manager "${packageManager}". Use npm, pnpm, yarn, or bun. Falling back to auto-detect.`
235+
`Unknown package manager "${packageManager}". Use npm, pnpm, yarn, or bun. Ignoring --packageManager; using npm_config_user_agent when it names a supported client, otherwise npm.`
224236
)
225237
);
226238
packageManager = undefined;

templates/README.md.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A Cloudinary React + Vite + TypeScript project scaffolded with [create-cloudinar
44

55
## Prerequisites
66

7-
- **Node.js** `^20.19.0` or `>=22.12.0` (matches `@vitejs/plugin-react` 5.x)
7+
- **Node.js** — use a current LTS release. Supported ranges are listed under `engines` in this `package.json`.
88

99
## Quick Start
1010

0 commit comments

Comments
 (0)