Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit90b4f26

Browse files
committed
refactor: remove redundant log, adjust variable naming and code order
1 parentbea584c commit90b4f26

File tree

1 file changed

+33
-34
lines changed

1 file changed

+33
-34
lines changed

‎generator/index.js

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module.exports = (api) => {
1616
prune:true
1717
})
1818

19+
constglobalAPITransform=require('./codemods/global-api')
20+
api.transformScript(api.entryFile,globalAPITransform)
21+
1922
if(api.hasPlugin('eslint')){
2023
api.extendPackage({
2124
devDependencies:{
@@ -52,6 +55,24 @@ module.exports = (api) => {
5255
})
5356
}
5457

58+
constresolveFile=(file)=>{
59+
if(!/\.(j|t)s$/ig.test(file)){
60+
file+='.js'
61+
}
62+
letresolvedPath=api.resolve(file)
63+
constpossiblePaths=[
64+
resolvedPath,
65+
resolvedPath.replace(/\.js$/ig,'.ts'),
66+
path.join(resolvedPath.replace(/\.js$/ig,''),'index.js'),
67+
path.join(resolvedPath.replace(/\.js$/ig,''),'index.ts')
68+
]
69+
for(constpofpossiblePaths){
70+
if(fs.existsSync(p)){
71+
returnpath.relative(api.resolve('.'),p)
72+
}
73+
}
74+
}
75+
5576
if(api.hasPlugin('vuex')||api.generator.pkg.dependencies['vuex']){
5677
api.extendPackage({
5778
dependencies:{
@@ -61,6 +82,12 @@ module.exports = (api) => {
6182

6283
api.exitLog('Installed vuex 4.0.')
6384
api.exitLog('See the documentation at https://github.com/vuejs/vuex/tree/4.0')
85+
86+
conststorePath=resolveFile('src/store')
87+
if(storePath){
88+
api.transformScript(storePath,globalAPITransform)
89+
api.transformScript(storePath,require('./codemods/vuex'))
90+
}
6491
}
6592

6693
if(api.hasPlugin('router')||api.generator.pkg.dependencies['router']){
@@ -72,44 +99,16 @@ module.exports = (api) => {
7299

73100
api.exitLog('Installed vue-router 4.0.')
74101
api.exitLog('See the documentation at https://github.com/vuejs/vue-router-next')
102+
103+
constrouterPath=resolveFile('src/router')
104+
if(routerPath){
105+
api.transformScript(routerPath,globalAPITransform)
106+
api.transformScript(routerPath,require('./codemods/router'))
107+
}
75108

76109
// Notes:
77110
// * Catch all routes (`/*`) must now be defined using a parameter with a custom regex: `/:catchAll(.*)`
78111
// * `keep-alive` is not yet supported
79112
// * Partial support of per-component navigation guards. No `beforeRouteEnter`
80113
}
81-
82-
constglobalApiTransform=require('./codemods/global-api')
83-
api.transformScript(api.entryFile,globalApiTransform)
84-
85-
constresolveFile=(file)=>{
86-
if(!/\.(j|t)s$/ig.test(file)){
87-
file+='.js'
88-
}
89-
letresolvedPath=api.resolve(file)
90-
constpossiblePaths=[
91-
resolvedPath,
92-
resolvedPath.replace(/\.js$/ig,'.ts'),
93-
path.join(resolvedPath.replace(/\.js$/ig,''),'index.js'),
94-
path.join(resolvedPath.replace(/\.js$/ig,''),'index.ts')
95-
]
96-
for(constpofpossiblePaths){
97-
if(fs.existsSync(p)){
98-
returnpath.relative(api.resolve('.'),p)
99-
}
100-
}
101-
}
102-
103-
constrouterPath=resolveFile('src/router')
104-
console.log(routerPath)
105-
if(routerPath){
106-
api.transformScript(routerPath,globalApiTransform)
107-
api.transformScript(routerPath,require('./codemods/router'))
108-
}
109-
110-
conststorePath=resolveFile('src/store')
111-
if(storePath){
112-
api.transformScript(storePath,globalApiTransform)
113-
api.transformScript(storePath,require('./codemods/vuex'))
114-
}
115114
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp