File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 22
33const { test} = require ( 'supertape' ) ;
44const tryCatch = require ( 'try-catch' ) ;
5+
56const {
67 parse,
78 operator,
Original file line number Diff line number Diff line change 33const { traverse, types} = require ( '@putout/babel' ) ;
44const { extract} = require ( '../extract' ) ;
55
6- const { isObjectExpression} = types ;
6+ const {
7+ isCallExpression,
8+ isObjectExpression,
9+ } = types ;
710
811const nodeOrPath = ( path ) => path . node || path ;
912
1013function getNode ( path ) {
1114 if ( ! isObjectExpression ( path ) )
1215 return nodeOrPath ( path ) ;
1316
17+ if ( isCallExpression ( path . parentPath ) )
18+ return path . parentPath . node ;
19+
1420 return {
1521 type : 'ExpressionStatement' ,
1622 expression : nodeOrPath ( path ) ,
Original file line number Diff line number Diff line change 33const { maybeBody} = require ( './maybe-body' ) ;
44const { assign} = Object ;
55
6+ const parseNode = ( a ) => {
7+ a = extractMark ( a ) ;
8+
9+ if ( a . node )
10+ return a . node ;
11+
12+ return a ;
13+ } ;
14+
615module . exports . replaceWith = ( path , node ) => {
7- node = extractMark ( node ) ;
16+ node = parseNode ( node ) ;
817
918 if ( path ?. parentPath ?. isExpressionStatement ( ) && ! path . parentPath . isProgram ( ) ) {
1019 addMark ( path , node ) ;
You can’t perform that action at this time.
0 commit comments