Skip to content

Commit 329c5cd

Browse files
committed
fix(remove): fix
1 parent 49a5781 commit 329c5cd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

scripts/remove-ChangedPayload.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,29 @@ function isNewExpressionChangedPayload(path) {
5252
module.exports = function transformer(file, api) {
5353
const j = api.jscodeshift;
5454
// Remove `import { ChangedPayload } from "almin"
55+
let hasAlmin = false;
56+
5557
return (
5658
j(
5759
j(file.source)
5860
.find(j.ImportSpecifier)
5961
.filter(path => {
60-
return isChangedPayloadImportSpecifier(path);
62+
hasAlmin = isChangedPayloadImportSpecifier(path);
63+
return hasAlmin;
6164
})
6265
.remove()
6366
.toSource()
6467
)
6568
// Rewrite new ChangedPayload() => { type: "ChangedPayload" }
6669
.find(j.NewExpression)
6770
.filter(path => {
68-
let newExpressionChangedPayload = isNewExpressionChangedPayload(path);
69-
console.log(newExpressionChangedPayload);
70-
return newExpressionChangedPayload;
71+
if (!hasAlmin) {
72+
return false;
73+
}
74+
return isNewExpressionChangedPayload(path);
7175
})
7276
.replaceWith(path => {
7377
return `{ type: "ChangedPayload" }`;
74-
R;
7578
})
7679
.toSource()
7780
);

0 commit comments

Comments
 (0)