Skip to content

Commit 72e487a

Browse files
committed
fix: @putout/operate: get back
1 parent 434e4f7 commit 72e487a

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

packages/operate/lib/properties/index.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const {test} = require('supertape');
44
const tryCatch = require('try-catch');
5+
56
const {
67
parse,
78
operator,

packages/operate/lib/properties/traverse-properties.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
const {traverse, types} = require('@putout/babel');
44
const {extract} = require('../extract');
55

6-
const {isObjectExpression} = types;
6+
const {
7+
isCallExpression,
8+
isObjectExpression,
9+
} = types;
710

811
const nodeOrPath = (path) => path.node || path;
912

1013
function 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),

packages/operate/lib/replace-with/replace-with.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,17 @@
33
const {maybeBody} = require('./maybe-body');
44
const {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+
615
module.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);

0 commit comments

Comments
 (0)