Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return mapLimit(event.stories, concurrency, async task => {
try {
const screenshot = await captureScreenshotForStory(target, {
kind: task.kind,
story: task.story,
configuration: task.configuration,
options: event.options,
});
return screenshot;
} catch (error) {
return { errorMessage: serializeError(unwrapError(error)) };
}
});
};
async function getStorybook() {
const url = `${baseUrl}/iframe.html`;
try {
const tab = await launchStoriesTab(url);
return tab.executeFunctionWithWindow(getStories);
} catch (rawError) {
const error = unwrapError(rawError);
if (
error instanceof TimeoutError ||
(error instanceof FetchingURLsError && error.failedURLs.includes(url))
) {
throw new ServerError(
'Failed fetching stories because the server is down',
`Try starting it with "yarn storybook" or pass the --port or --host arguments if it's not running at ${baseUrl}`
);
}
throw error;
}
}
async function run() {
const args = process.argv.slice(2);
const argv = minimist(args);
const command = argv._[0] || 'test';
const executor = getExecutorForCommand(command);
bold(`loki ${command} v${version}`);
try {
await executor(args);
} catch (rawError) {
const error = unwrapError(rawError);
if (
error instanceof MissingDependencyError ||
error instanceof ServerError ||
error instanceof ChromeError ||
error instanceof FetchingURLsError
) {
die(error.message, error.instructions);
}
const childProcessFailed =
error.cmd &&
error.stderr &&
error.message.indexOf('Command failed: ') === 0;
if (childProcessFailed) {
die(error.stderr);