Skip to content

Commit

Permalink
fix(create): Resolve package manager commands correctly in next steps (
Browse files Browse the repository at this point in the history
…#360)

* fix next steps message for deno

* changeset
  • Loading branch information
AdrianGonz97 authored Dec 23, 2024
1 parent bc7dcb6 commit b25077c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/chatty-queens-judge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

fix: correctly resolve package manager commands in `create`'s next-steps
10 changes: 6 additions & 4 deletions packages/cli/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@sveltejs/create';
import * as common from '../utils/common.ts';
import { runAddCommand } from './add/index.ts';
import { detectSync, type AgentName } from 'package-manager-detector';
import { detectSync, resolveCommand, type AgentName } from 'package-manager-detector';
import {
getUserAgent,
installDependencies,
Expand Down Expand Up @@ -72,14 +72,16 @@ export const create = new Command('create')
);
}
if (!packageManager) {
initialSteps.push(`${i++}: ${highlight(`${pm} install`)}`);
const { args, command } = resolveCommand(pm, 'install', [])!;
initialSteps.push(`${i++}: ${highlight(`${command} ${args.join(' ')}`)}`);
}

const pmRun = pm === 'npm' ? 'npm run dev --' : `${pm} dev`;
const { args, command } = resolveCommand(pm, 'run', ['dev', '--open'])!;
const pmRunCmd = `${command} ${args.join(' ')}`;
const steps = [
...initialSteps,
`${i++}: ${highlight('git init && git add -A && git commit -m "Initial commit"')} (optional)`,
`${i++}: ${highlight(`${pmRun} --open`)}`,
`${i++}: ${highlight(pmRunCmd)}`,
'',
`To close the dev server, hit ${highlight('Ctrl-C')}`,
'',
Expand Down

0 comments on commit b25077c

Please sign in to comment.