Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "fixture flowchart" to docs #4440

Merged
merged 2 commits into from Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added assets/mocha-fixture-wizard.sketch
Binary file not shown.
56 changes: 32 additions & 24 deletions docs/_data/supporters.js
Expand Up @@ -99,32 +99,40 @@ const nodeToSupporter = node => ({
categories: node.fromAccount.categories
});

const fetchImage = async supporter => {
try {
const {avatar: url} = supporter;
const {body: imageBuf, headers} = await needle('get', url, {timeout: 2000});
if (headers['content-type'].startsWith('text/html')) {
throw new TypeError('received html and expected a png; outage likely');
const fetchImage = process.env.MOCHA_DOCS_SKIP_IMAGE_DOWNLOAD
? async supporter => {
invalidSupporters.push(supporter);
}
debug('fetched %s', url);
const canvasImage = await loadImage(imageBuf);
debug('ok %s', url);
supporter.dimensions = {
width: canvasImage.width,
height: canvasImage.height
: async supporter => {
try {
const {avatar: url} = supporter;
const {body: imageBuf, headers} = await needle('get', url, {
timeout: 2000
});
if (headers['content-type'].startsWith('text/html')) {
throw new TypeError(
'received html and expected a png; outage likely'
);
}
debug('fetched %s', url);
const canvasImage = await loadImage(imageBuf);
debug('ok %s', url);
supporter.dimensions = {
width: canvasImage.width,
height: canvasImage.height
};
// debug('dimensions %s %dw %dh', url, canvasImage.width, canvasImage.height);
const filePath = resolve(SUPPORTER_IMAGE_PATH, supporter.id + '.png');
await writeFile(filePath, imageBuf);
debug('wrote %s', filePath);
} catch (err) {
console.error(
`failed to load ${supporter.avatar}; will discard ${supporter.tier} "${supporter.name} (${supporter.slug}). reason:\n`,
err
);
invalidSupporters.push(supporter);
}
};
// debug('dimensions %s %dw %dh', url, canvasImage.width, canvasImage.height);
const filePath = resolve(SUPPORTER_IMAGE_PATH, supporter.id + '.png');
await writeFile(filePath, imageBuf);
debug('wrote %s', filePath);
} catch (err) {
console.error(
`failed to load ${supporter.avatar}; will discard ${supporter.tier} "${supporter.name} (${supporter.slug}). reason:\n`,
err
);
invalidSupporters.push(supporter);
}
};

/**
* Retrieves donation data from OC
Expand Down