2022-11-26 02:31:26 +00:00
|
|
|
|
package service
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"github.com/huoxue1/qinglong-go/utils"
|
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
|
"os"
|
|
|
|
|
"path"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func AppInit() {
|
|
|
|
|
go runYarn()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func runYarn() {
|
|
|
|
|
defer func() {
|
|
|
|
|
recover()
|
|
|
|
|
}()
|
|
|
|
|
_, err := os.Stat(path.Join("data", "scripts", "package.json"))
|
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
ch := make(chan int, 1)
|
2023-02-05 04:25:36 +00:00
|
|
|
|
utils.RunTask(context.WithValue(context.Background(), "cancel", ch), "pnpm install", map[string]string{}, func(ctx context.Context) {
|
|
|
|
|
log.Infoln("开始执行pnpm初始化!")
|
2022-11-26 02:31:26 +00:00
|
|
|
|
}, func(ctx context.Context) {
|
2023-02-05 04:25:36 +00:00
|
|
|
|
log.Infoln("pnpm初始化执行完成!")
|
2022-11-26 02:31:26 +00:00
|
|
|
|
}, os.Stdout)
|
|
|
|
|
}
|