Skip to content

Commit b388b0a

Browse files
authoredAug 13, 2023
fix(cli/init): print the correct packageManager (#2787)
1 parent 4d9d977 commit b388b0a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎src/node/init/init.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export interface ScaffoldOptions {
2828
injectNpmScripts: boolean
2929
}
3030

31+
const getPackageManger = () => {
32+
const name = process.env?.npm_config_user_agent || 'npm'
33+
if (name === 'npm') {
34+
return 'npm'
35+
}
36+
return name.split('/')[0]
37+
}
38+
3139
export async function init() {
3240
intro(bold(cyan(' Welcome to VitePress! ')))
3341

@@ -196,7 +204,9 @@ export function scaffold({
196204
}
197205
Object.assign(userPkg.scripts || (userPkg.scripts = {}), scripts)
198206
fs.writeFileSync(pkgPath, JSON.stringify(userPkg, null, 2))
199-
return `Done! Now run ${cyan(`npm run docs:dev`)} and start writing.${tip}`
207+
return `Done! Now run ${cyan(
208+
`${getPackageManger()} run docs:dev`
209+
)} and start writing.${tip}`
200210
} else {
201211
return `You're all set! Now run ${cyan(
202212
`npx vitepress dev${dir}`

0 commit comments

Comments
 (0)
Please sign in to comment.