Skip to content

Commit b25077c

Browse files
authored
fix(create): Resolve package manager commands correctly in next steps (#360)
* fix next steps message for deno * changeset
1 parent bc7dcb6 commit b25077c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

.changeset/chatty-queens-judge.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
fix: correctly resolve package manager commands in `create`'s next-steps

packages/cli/commands/create.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from '@sveltejs/create';
1414
import * as common from '../utils/common.ts';
1515
import { runAddCommand } from './add/index.ts';
16-
import { detectSync, type AgentName } from 'package-manager-detector';
16+
import { detectSync, resolveCommand, type AgentName } from 'package-manager-detector';
1717
import {
1818
getUserAgent,
1919
installDependencies,
@@ -72,14 +72,16 @@ export const create = new Command('create')
7272
);
7373
}
7474
if (!packageManager) {
75-
initialSteps.push(`${i++}: ${highlight(`${pm} install`)}`);
75+
const { args, command } = resolveCommand(pm, 'install', [])!;
76+
initialSteps.push(`${i++}: ${highlight(`${command} ${args.join(' ')}`)}`);
7677
}
7778

78-
const pmRun = pm === 'npm' ? 'npm run dev --' : `${pm} dev`;
79+
const { args, command } = resolveCommand(pm, 'run', ['dev', '--open'])!;
80+
const pmRunCmd = `${command} ${args.join(' ')}`;
7981
const steps = [
8082
...initialSteps,
8183
`${i++}: ${highlight('git init && git add -A && git commit -m "Initial commit"')} (optional)`,
82-
`${i++}: ${highlight(`${pmRun} --open`)}`,
84+
`${i++}: ${highlight(pmRunCmd)}`,
8385
'',
8486
`To close the dev server, hit ${highlight('Ctrl-C')}`,
8587
'',

0 commit comments

Comments
 (0)