UNPKG

create-esmx

Version:

A scaffold tool for creating Esmx projects

50 lines (49 loc) 1.36 kB
const PACKAGE_MANAGER_CONFIG = { npm: { install: "npm install", dev: "npm run dev", build: "npm run build", start: "npm start", create: "npm create esmx@latest", "build:type": "npm run build:type", "lint:type": "npm run lint:type" }, yarn: { install: "yarn install", dev: "yarn dev", build: "yarn build", start: "yarn start", create: "yarn create esmx", "build:type": "yarn build:type", "lint:type": "yarn lint:type" }, pnpm: { install: "pnpm install", dev: "pnpm dev", build: "pnpm build", start: "pnpm start", create: "pnpm create esmx", "build:type": "pnpm build:type", "lint:type": "pnpm lint:type" }, bun: { install: "bun install", dev: "bun dev", build: "bun run build", start: "bun start", create: "bun create esmx", "build:type": "bun run build:type", "lint:type": "bun run lint:type" } }; function detectPackageManager(userAgent) { const agent = userAgent || process.env.npm_config_user_agent || ""; if (agent.includes("pnpm")) return "pnpm"; if (agent.includes("yarn")) return "yarn"; if (agent.includes("bun")) return "bun"; return "npm"; } export function getCommand(commandType, userAgent) { const packageManager = detectPackageManager(userAgent); return PACKAGE_MANAGER_CONFIG[packageManager][commandType]; }