node-karin 0.6.19 → 0.6.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cli/init.js +10 -4
- package/package.json +1 -1
package/lib/cli/init.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { select } from '@inquirer/prompts'
|
|
3
|
-
import { common } from '../utils/index.js'
|
|
4
3
|
import { KarinInit } from '../utils/init.js'
|
|
4
|
+
/**
|
|
5
|
+
* 休眠函数
|
|
6
|
+
* @param ms 毫秒
|
|
7
|
+
*/
|
|
8
|
+
function sleep (ms) {
|
|
9
|
+
return new Promise(resolve => setTimeout(resolve, ms))
|
|
10
|
+
}
|
|
5
11
|
async function main () {
|
|
6
12
|
/** 捕获错误 打印日志 */
|
|
7
13
|
process.on('uncaughtException', err => console.error(err))
|
|
8
14
|
process.on('unhandledRejection', err => console.error(err))
|
|
9
15
|
const init = new KarinInit()
|
|
10
16
|
init.init()
|
|
11
|
-
await
|
|
17
|
+
await sleep(1000)
|
|
12
18
|
const prompt = await select({
|
|
13
19
|
message: '请选择npm源 中国大陆服务器一定要更换!!!',
|
|
14
20
|
choices: [
|
|
@@ -17,10 +23,10 @@ async function main () {
|
|
|
17
23
|
],
|
|
18
24
|
})
|
|
19
25
|
console.log('正在更换npm源...请稍等~')
|
|
20
|
-
await
|
|
26
|
+
await sleep(1000)
|
|
21
27
|
/** 结果 */
|
|
22
28
|
await init.changeRegistry(prompt)
|
|
23
|
-
await
|
|
29
|
+
await sleep(1000)
|
|
24
30
|
const pkg = await select({
|
|
25
31
|
message: '请选择包管理器 如果不知道怎么选 请选pnpm',
|
|
26
32
|
choices: [
|