Skip to content

Commit

Permalink
fix: Fix not running on reinstall deps
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauro Titimoli committed Jun 26, 2019
1 parent f7d3892 commit 073a695
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,36 @@ import * as withState from "./cliState";

const jetificableGroupsPath = "./jetificableGroups.json";

const finish = (rnJetifier, jetificableGroups) =>
const saveAndJetifyJetificableGroups = (rnJetifier, jetificableGroups) =>
withJetificableGroup
.save(jetificableGroupsPath, jetificableGroups)
.then(() => withJetificableGroup.jetifyAll(rnJetifier, jetificableGroups));

const onJetificableGroups = (state, rnJetifier) => jetificableGroups =>
finish(rnJetifier, [...state.jetificableGroups, ...jetificableGroups]);
saveAndJetifyJetificableGroups(rnJetifier, [
...state.jetificableGroups,
...jetificableGroups
]);

const onRnJetifier = state => rnJetifier =>
const retrieveJetificableGroups = (rnJetifier, state) =>
withJetificableGroup
.retrieveAllFrom(rnJetifier, state.packageInfos)
.then(onJetificableGroups(state, rnJetifier));

const start = state => withRnJetifier.retrieve().then(onRnJetifier(state));

const onState = state => {
const onRetrieveDependencies = ([rnJetifier, state]) => {
if (state.packageInfos.length > 0) {
start(state);
retrieveJetificableGroups(rnJetifier, state);
} else {
withJetificableGroup.jetifyAll(rnJetifier, state.jetificableGroups);
}
};

const run = () => withState.create(jetificableGroupsPath).then(onState);
const retrieveDependencies = () =>
Promise.all([
withRnJetifier.retrieve(),
withState.create(jetificableGroupsPath)
]);

const run = () => retrieveDependencies().then(onRetrieveDependencies);

export {run};

0 comments on commit 073a695

Please sign in to comment.