Merge pull request #4213 from Keraito/cli-gestorybook-fix

Cli gestorybook fix
This commit is contained in:
Pavan Kumar Sunkara 2018-09-24 14:43:01 +02:00 committed by GitHub
commit dd1953c953
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 36 deletions

View File

@ -12,39 +12,38 @@ if (process.argv[1].includes('getstorybook')) {
logger.log(chalk.yellow('The official command to install Storybook from now on is:\n'));
codeLog(['storybook init']);
logger.log();
initiate({}, pkg);
process.exit(0);
}
program
.command('init')
.description('Initialize Storybook into your project.')
.option('-f --force', 'Forcely add storybook')
.option('-s --skip-install', 'Skip installing deps')
.option('-N --use-npm', 'Use npm to install deps')
.option('-p --parser <babel | babylon | flow>', 'jscodeshift parser')
.option('-h --html', 'Add storybook for HTML')
.action(options => initiate(options, pkg));
program
.command('start')
.description('Start the local Storybook server')
.option('-N --use-npm', 'Use NPM to start the Storybook server')
.action(options => yarnSpawnSync(options, ['run', 'storybook']));
program
.command('build')
.description('Build the Storybook static application')
.option('-N --use-npm', 'Use NPM to build the Storybook server')
.action(options => yarnSpawnSync(options, ['build', 'storybook']));
program.command('*', { noHelp: true }).action(cmd => {
logger.error('Invalid command: %s.\nSee --help for a list of available commands.', cmd);
process.exit(1);
});
program.version(pkg.version).parse(process.argv);
if (!program.args.length) {
program.help();
initiate({}, pkg).then(() => process.exit(0));
} else {
program
.command('init')
.description('Initialize Storybook into your project.')
.option('-f --force', 'Forcely add storybook')
.option('-s --skip-install', 'Skip installing deps')
.option('-N --use-npm', 'Use npm to install deps')
.option('-p --parser <babel | babylon | flow>', 'jscodeshift parser')
.option('-h --html', 'Add storybook for HTML')
.action(options => initiate(options, pkg));
program
.command('start')
.description('Start the local Storybook server')
.option('-N --use-npm', 'Use NPM to start the Storybook server')
.action(options => yarnSpawnSync(options, ['run', 'storybook']));
program
.command('build')
.description('Build the Storybook static application')
.option('-N --use-npm', 'Use NPM to build the Storybook server')
.action(options => yarnSpawnSync(options, ['build', 'storybook']));
program.command('*', { noHelp: true }).action(cmd => {
logger.error('Invalid command: %s.\nSee --help for a list of available commands.', cmd);
process.exit(1);
});
program.version(pkg.version).parse(process.argv);
if (!program.args.length) {
program.help();
}
}

View File

@ -185,7 +185,7 @@ export default function(options, pkg) {
}
};
runGenerator().catch(ex => {
return runGenerator().catch(ex => {
logger.error(`\n ${chalk.red(ex.stack)}`);
process.exit(1);
});