Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
try {
// Channel for addons is created by storybook manager from the client side.
// We need to polyfill it for the server side.
const addons = require('@kadira/storybook-addons').default;
const channel = new EventEmitter();
addons.setChannel(channel);
const content = babel.transformFileSync(configPath, babelConfig).code;
const contextOpts = {
filename: configPath,
dirname: path.resolve(configDir),
};
runWithRequireContext(content, contextOpts);
const storybook = require('@kadira/storybook').getStorybook();
const result = await runner.run(filterStorybook(storybook, grep, exclude));
const fails = result.errored + result.unmatched;
const exitCode = fails > 0 ? 1: 0;
if(!program.watch){
process.exit(exitCode);
}
} catch (e) {
console.log(e.stack || e);
if(!program.watch){
process.exit(1);
}
}
}
global.navigator.userAgent = 'screener';
// Channel for addons is created by storybook manager from the client side.
// We need to polyfill it for the server side.
var addons = require('@kadira/storybook-addons').default;
var channel = new EventEmitter();
addons.setChannel(channel);
var content = babel.transformFileSync(configPath, babelConfig).code;
var contextOpts = {
filename: configPath,
dirname: path.resolve(configDir),
};
try {
runWithRequireContext(content, contextOpts);
var storybook = require('@kadira/storybook').getStorybook();
callback(null, storybook);
} catch(ex) {
if (!options || !options.port) return callback(ex);
// Exception may be caused by global dependencies injected into browser's Window object.
// We are not running through an actual browser, so try JSDom.
var jsdom = require('jsdom');
var request = require('request');
// try to retrieve preview bundle from local storybook server
request.get('http://localhost:' + options.port + '/static/preview.bundle.js', function(err, response, body) {
if (err || response.statusCode != 200 || !body) return callback(ex);
if (options.debug && ex.stack) {
console.log('DEBUG:', ex.stack);
} else {
console.log(ex.message || ex.toString());
}
console.log('Retrying...');