Skip to content

Commit

Permalink
add "fixture flowchart" to docs (mochajs#4440)
Browse files Browse the repository at this point in the history
- add "fixture flowchart wizard" to docs
- added source `.sketch` file to repo
- enabled skip of supporter image download in 11ty via env var `MOCHA_DOCS_SKIP_IMAGE_DOWNLOAD` for faster iteration
- made the links underline on hover
- Ref: mochajs#4308 

Signed-off-by: Christopher Hiller <[email protected]>
  • Loading branch information
boneskull authored Oct 12, 2020
1 parent 9c28990 commit 478ca6a
Show file tree
Hide file tree
Showing 5 changed files with 487 additions and 25 deletions.
Binary file added assets/mocha-fixture-wizard.sketch
Binary file not shown.
56 changes: 32 additions & 24 deletions docs/_data/supporters.js
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 478ca6a

Please sign in to comment.