File tree Expand file tree Collapse file tree
transforms/update-triggerevent-file-param Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,16 +8,22 @@ module.exports = function transformer(file, api) {
88 * A transform to update param in `triggerEvent` from `[ file ]` to `{ files: [ file ] }`
99 */
1010 function transform ( ) {
11- root . find ( j . CallExpression , {
12- callee : {
13- name : 'triggerEvent'
14- }
15- } ) . find ( j . ArrayExpression ) . replaceWith ( path => {
16- // make sure we just modify the arrayExpression which is the param of triggerEvent call expression
17- if ( path . parent . node . type === 'CallExpression' && path . parent . node . callee . name === 'triggerEvent' ) {
18- return j . objectExpression ( [ j . property ( 'init' , j . identifier ( 'files' ) , path . node ) ] )
19- } else return path . node
20- } )
11+ root
12+ . find ( j . CallExpression , {
13+ callee : {
14+ name : 'triggerEvent' ,
15+ } ,
16+ } )
17+ . find ( j . ArrayExpression )
18+ . replaceWith ( ( path ) => {
19+ // make sure we just modify the arrayExpression which is the param of triggerEvent call expression
20+ if (
21+ path . parent . node . type === 'CallExpression' &&
22+ path . parent . node . callee . name === 'triggerEvent'
23+ ) {
24+ return j . objectExpression ( [ j . property ( 'init' , j . identifier ( 'files' ) , path . node ) ] ) ;
25+ } else return path . node ;
26+ } ) ;
2127 }
2228
2329 transform ( ) ;
@@ -26,4 +32,4 @@ module.exports = function transformer(file, api) {
2632 quote : 'single' ,
2733 trailingComma : false ,
2834 } ) ;
29- }
35+ } ;
You can’t perform that action at this time.
0 commit comments