提交 777dac29 编写于 作者: 雪洛's avatar 雪洛

fix: require hooks error

上级 82c75412
const path = require('path')
const fs = require('fs')
const {
getWeixinPlatform
} = require('./weixin')
const createConfig = require('uni-config-center')
const requiredConfig = {
'web.h5-weixin': ['appid', 'appsecret'],
......@@ -13,6 +12,11 @@ const requiredConfig = {
'mp-alipay.alipay': ['appid', 'privateKey'],
'app.apple': ['bundleId']
}
const uniIdConfig = createConfig({
pluginId: 'uni-id'
})
class ConfigUtils {
constructor ({
context
......@@ -61,14 +65,17 @@ class ConfigUtils {
getPlatformConfig () {
const appConfig = this.getAppConfig()
if (!appConfig) {
throw new Error(`Config for current app (${this.appId}) was not found, please check your config file or client appId`)
throw new Error(
`Config for current app (${this.appId}) was not found, please check your config file or client appId`)
}
const platform = this.platform
if (
(this.platform === 'app' && appConfig['app-plus']) ||
(this.platform === 'web' && appConfig.h5)
) {
throw new Error(`Client platform is ${this.platform}, but ${this.platform === 'web' ? 'h5' : 'app-plus'} was found in config. Please refer to: https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary?id=m-to-co`)
throw new Error(
`Client platform is ${this.platform}, but ${this.platform === 'web' ? 'h5' : 'app-plus'} was found in config. Please refer to: https://uniapp.dcloud.net.cn/uniCloud/uni-id-summary?id=m-to-co`
)
}
const defaultConfig = {
......@@ -116,10 +123,10 @@ class ConfigUtils {
}
getHooks () {
const configPath = require.resolve('uni-config-center/uni-id')
const hookPath = path.resolve(configPath, 'hooks/index.js')
if (fs.existsSync(hookPath)) {
return require(hookPath)
if (uniIdConfig.hasFile('hooks/index.js')) {
return require(
uniIdConfig.resolve('hooks/index.js')
)
}
return {}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册