Skip to content

Commit

Permalink
refactor: using map for remote image name creation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaliabadi committed Jun 18, 2018
1 parent 1ff44c3 commit fb7dbd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/bin/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ program
createDirectories(fs, config);
clearDirectory(fs, config);
createBucket(config);
await fetchRemoteComparisonImages(fs, config);
await fetchRemoteComparisonImages(config);
await createComparisons(fs, config);
});

Expand Down
27 changes: 15 additions & 12 deletions src/comparisonActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,23 @@ const clearDirectory = (fs, config) => {
});
};

const fetchRemoteComparisonImages = async (key, config) => {
const fetchRemoteComparisonImages = async config => {
if (config.remote) {
await deleteRemote('generatedDiffs', config);
for (let i = 0; i < config.scenarios.length; i++) {
for (let j = 0; j < config.scenarios[i].viewports.length; j++) {
await fetchRemote(
config,
'baseline',
`${config.scenarios[i].label}-${
config.scenarios[i].viewports[j].label
}.png`
);
}
}
return Promise.all(
config.scenarios.map(scenario =>
scenario.viewports.map(viewport => {
const promises = [];
const fetchRemotePromise = fetchRemote(
config,
'baseline',
`${scenario.label}-${viewport.label}.png`
);
promises.push(fetchRemotePromise);
return Promise.all(promises);
})
)
);
}
};

Expand Down

0 comments on commit fb7dbd0

Please sign in to comment.