File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -254,14 +254,17 @@ async function init() {
254254
255255 write ( 'package.json' , JSON . stringify ( pkg , null , 2 ) )
256256
257- const pkgManager = / y a r n / . test ( process . env . npm_execpath ) ? 'yarn' : 'npm'
257+ const pkgManager =
258+ pmFromUserAgent ( process . env . npm_config_user_agent ) ?. name || 'npm'
258259
259260 console . log ( `\nDone. Now run:\n` )
260261 if ( root !== cwd ) {
261262 console . log ( ` cd ${ path . relative ( cwd , root ) } ` )
262263 }
263- console . log ( ` ${ pkgManager === 'yarn' ? `yarn` : `npm install` } ` )
264- console . log ( ` ${ pkgManager === 'yarn' ? `yarn dev` : `npm run dev` } ` )
264+ console . log ( ` ${ pkgManager === 'yarn' ? `yarn` : `${ pkgManager } install` } ` )
265+ console . log (
266+ ` ${ pkgManager === 'yarn' ? `yarn dev` : `${ pkgManager } run dev` } `
267+ )
265268 console . log ( )
266269}
267270
@@ -318,6 +321,20 @@ function emptyDir(dir) {
318321 }
319322}
320323
324+ /**
325+ * @param {string | undefined } userAgent process.env.npm_config_user_agent
326+ * @returns object | undefined
327+ */
328+ function pmFromUserAgent ( userAgent ) {
329+ if ( ! userAgent ) return undefined
330+ const pmSpec = userAgent . split ( ' ' ) [ 0 ]
331+ const pmSpecArr = pmSpec . split ( '/' )
332+ return {
333+ name : pmSpecArr [ 0 ] ,
334+ version : pmSpecArr [ 1 ]
335+ }
336+ }
337+
321338init ( ) . catch ( ( e ) => {
322339 console . error ( e )
323340} )
You can’t perform that action at this time.
0 commit comments