Skip to content

Commit

Permalink
fix(remove): fix
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jan 17, 2018
1 parent 49a5781 commit 329c5cd
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions scripts/remove-ChangedPayload.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,29 @@ function isNewExpressionChangedPayload(path) {
module.exports = function transformer(file, api) {
const j = api.jscodeshift;
// Remove `import { ChangedPayload } from "almin"
let hasAlmin = false;

return (
j(
j(file.source)
.find(j.ImportSpecifier)
.filter(path => {
return isChangedPayloadImportSpecifier(path);
hasAlmin = isChangedPayloadImportSpecifier(path);
return hasAlmin;
})
.remove()
.toSource()
)
// Rewrite new ChangedPayload() => { type: "ChangedPayload" }
.find(j.NewExpression)
.filter(path => {
let newExpressionChangedPayload = isNewExpressionChangedPayload(path);
console.log(newExpressionChangedPayload);
return newExpressionChangedPayload;
if (!hasAlmin) {
return false;
}
return isNewExpressionChangedPayload(path);
})
.replaceWith(path => {
return `{ type: "ChangedPayload" }`;
R;
})
.toSource()
);
Expand Down

0 comments on commit 329c5cd

Please # to comment.