mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-21 05:02:39 +08:00
Make the code cleaner by extracting the checkRef into it's own function
This commit is contained in:
parent
26f11fe6c7
commit
627cee152e
@ -37,6 +37,12 @@ const getAutoRefs = async (options) => {
|
||||
return list.filter(Boolean);
|
||||
};
|
||||
|
||||
const checkRef = (url) =>
|
||||
fetch(`${url}/iframe.html`).then(
|
||||
({ ok }) => ok,
|
||||
() => false
|
||||
);
|
||||
|
||||
const stripTrailingSlash = (url) => url.replace(/\/$/, '');
|
||||
|
||||
const toTitle = (input) => {
|
||||
@ -96,9 +102,7 @@ async function getManagerWebpackConfig(options, presets) {
|
||||
// verify the refs are publicly reachable, if they are not we'll require stories.json at runtime, otherwise the ref won't work
|
||||
await Promise.all(
|
||||
Object.entries(refs).map(async ([k, value]) => {
|
||||
const { ok } = await fetch(`${value.url}/iframe.html`).catch((e) => ({
|
||||
ok: false,
|
||||
}));
|
||||
const ok = checkRef(value.url);
|
||||
|
||||
refs[k] = { ...value, type: ok ? 'server-checked' : 'unknown' };
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user