File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,6 +12,14 @@ const warnOnceSet = /* @__PURE__ */ new Set<string>()
1212
1313const DEFAULT_ENDPOINT = 'https://api.iconify.design'
1414
15+ function getInstallCommand ( pkg : string ) : string {
16+ const ua = process . env . npm_config_user_agent || ''
17+ if ( ua . startsWith ( 'pnpm' ) ) return `pnpm add -D ${ pkg } `
18+ if ( ua . startsWith ( 'yarn' ) ) return `yarn add -D ${ pkg } `
19+ if ( ua . startsWith ( 'bun' ) ) return `bun add -D ${ pkg } `
20+ return `npm i -D ${ pkg } `
21+ }
22+
1523export default defineCachedEventHandler ( async ( event : H3Event ) => {
1624 const url = getRequestURL ( event ) as URL
1725 if ( ! url )
@@ -41,7 +49,7 @@ export default defineCachedEventHandler(async (event: H3Event) => {
4149 if ( collectionName && ! warnOnceSet . has ( collectionName ) && apiEndPoint === DEFAULT_ENDPOINT ) {
4250 consola . warn ( [
4351 `[Icon] Collection \`${ collectionName } \` is not found locally` ,
44- `We suggest to install it via \`npm i -D @iconify-json/${ collectionName } \` to provide the best end-user experience.` ,
52+ `We suggest to install it via \`${ getInstallCommand ( ` @iconify-json/${ collectionName } ` ) } \` to provide the best end-user experience.` ,
4553 ] . join ( '\n' ) )
4654 warnOnceSet . add ( collectionName )
4755 }
You can’t perform that action at this time.
0 commit comments