Skip to content

Commit f4de2e5

Browse files
author
zhengyanan18
committed
refactor: 移除无用代码
1 parent a337746 commit f4de2e5

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

Diff for: packages/taro-cli/postinstall.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,11 @@ const axios = require('axios')
33

44
axios.get('https://taro.jd.com/', { timeout: 5000 })
55
.then(() => {
6-
// JD内网
7-
// console.log('*******JD内网:*******')
8-
exec('taro global-config add-plugin @jdtaro/plugin-build-report-performance@latest --registry http://registry.m.jd.com', (error, stdout, stderr) => {
6+
exec('taro global-config add-plugin @jdtaro/plugin-build-report-performance@latest --registry http://registry.m.jd.com', (error, _stdout, _stderr) => {
97
if (error) {
108
console.error(`install performance plugin error: ${error}`)
11-
return
129
}
13-
console.log(`install performance plugin stdout: ${stdout}`)
14-
console.log(`install performance plugin stderr: ${stderr}`)
1510
})
1611
})
1712
.catch(() => {
18-
// 公网
19-
// console.log('*******公网:*******')
2013
})

Diff for: packages/taro-service/src/Config.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class Config {
3636
isInitSuccess: boolean
3737
disableGlobalConfig: boolean
3838

39-
constructor(opts: IConfigOptions) {
39+
constructor (opts: IConfigOptions) {
4040
this.appPath = opts.appPath
4141
this.disableGlobalConfig = !!opts?.disableGlobalConfig
4242
}
@@ -51,10 +51,8 @@ export default class Config {
5151
this.configPath = resolveScriptPath(path.join(this.appPath, CONFIG_DIR_NAME, DEFAULT_CONFIG_FILE))
5252
if (!fs.existsSync(this.configPath)) {
5353
if (this.disableGlobalConfig) return
54-
// 没有项目config,说明是全局命令,加载所有全局插件
5554
this.initGlobalConfig()
5655
} else {
57-
// 有项目config,说明是Taro项目内命令,加载该命令相关的全局插件`@jdtaro/plugin-${command}...`
5856
this.initGlobalConfig(configEnv.command)
5957
createSwcRegister({
6058
only: [

Diff for: packages/taro-service/src/utils/index.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,18 @@ export function printHelpLog (command, optionsList: Map<string, string>, synopsi
118118
}
119119
}
120120

121-
// 对于全局配置,如果command为空,则返回全部。否则只返回command相关的插件和presets
122121
export function filterGlobalConfig (globalConfig: IProjectConfig, command: string) {
123122
if (!command) {
124123
return globalConfig
125124
}
126125
const config = globalConfig
127126

128-
// 如果有command,则只留下command相关的plugin
129127
const RelatedPluginTag = `@jdtaro/plugin-${command}`
130-
if (config.plugins) {
128+
if (config.plugins?.length) {
131129
config.plugins = config.plugins.filter(pluginName => {
132130
return pluginName.includes(RelatedPluginTag)
133131
})
134132
}
135133

136-
// TODO:如果有presets,则只留下command相关的presets.当前无这样的需求
137134
return config
138135
}

0 commit comments

Comments
 (0)