File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ module . exports = function ( files , filename ) {
2
+ let content = files [ filename ]
3
+ content = removeEventNative ( content )
4
+ content = addTransitionFrom ( content )
5
+ files [ filename ] = content
6
+ }
7
+
8
+ // template
9
+ // v-on:event.native => v-on:event
10
+ // @event .native => @event
11
+ function removeEventNative ( content ) {
12
+ const reg = new RegExp (
13
+ '(?<=<template>[\\s\\S]*?\\s(?:v-on:|@)\\w+).native(?==[\\s\\S]*?</template>)' ,
14
+ 'g'
15
+ )
16
+ return content . replace ( reg , '' )
17
+ }
18
+
19
+ // style
20
+ // .xxx-enter => .xxx-enter-from
21
+ // .xxx-leave => .xxx-leave-from
22
+ function addTransitionFrom ( content ) {
23
+ const reg = new RegExp (
24
+ '(?<=<style[\\s>][\\s\\S]*?\\s\\.[A-Za-z0-9_-]+-)(enter|leave)(?=[,{\\s][\\s\\S]*?</style>)' ,
25
+ 'g'
26
+ )
27
+ return content . replace ( reg , '$1-from' )
28
+ }
Original file line number Diff line number Diff line change @@ -134,3 +134,15 @@ module.exports = (api) => {
134
134
api . exitLog ( 'Documentation available at https://github.com/vuejs/vue-test-utils-next' )
135
135
}
136
136
}
137
+
138
+ module . exports . hooks = api => {
139
+ api . postProcessFiles ( files => {
140
+ const vueTransform = require ( './codemods/vue-addition' )
141
+ const vueFiles = Object . keys ( api . generator . files ) . filter ( el =>
142
+ el . endsWith ( '.vue' )
143
+ )
144
+ for ( let i = 0 ; i < vueFiles . length ; i ++ ) {
145
+ vueTransform ( files , vueFiles [ i ] )
146
+ }
147
+ } )
148
+ }
You can’t perform that action at this time.
0 commit comments