Skip to content

Commit

Permalink
fix(cli/init): print the correct packageManager (#2787)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed Aug 13, 2023
1 parent 4d9d977 commit b388b0a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/node/init/init.ts
Expand Up @@ -28,6 +28,14 @@ export interface ScaffoldOptions {
injectNpmScripts: boolean
}

const getPackageManger = () => {
const name = process.env?.npm_config_user_agent || 'npm'
if (name === 'npm') {
return 'npm'
}
return name.split('/')[0]
}

export async function init() {
intro(bold(cyan(' Welcome to VitePress! ')))

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

0 comments on commit b388b0a

Please sign in to comment.