forked from vitejs/vite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·43 lines (34 loc) · 855 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env node
/* eslint-disable node/shebang */
const { yellow, green } = require('kolorist')
const alternativeCommands = {
yarn: 'yarn create vite',
pnpm: 'pnpm dlx create-vite',
npm: 'npm init vite',
unknown: 'npm init vite'
}
function getPackageManager() {
if (!process.env.npm_execpath) {
return 'unknown'
}
if (process.env.npm_execpath.indexOf('yarn') !== -1) {
return 'yarn'
}
if (process.env.npm_execpath.indexOf('pnpm') !== -1) {
return 'pnpm'
}
if (process.env.npm_execpath.indexOf('npm') !== -1) {
return 'npm'
}
return 'unknown'
}
const packageManager = getPackageManager()
const alternativeCommand = alternativeCommands[packageManager]
console.warn(
yellow(
`\n@vitejs/create-app is deprecated, use ${green(
alternativeCommand
)} instead\n`
)
)
require('create-vite')