Skip to content

Commit

Permalink
Merge pull request #4213 from Keraito/cli-gestorybook-fix
Browse files Browse the repository at this point in the history
Cli gestorybook fix
  • Loading branch information
pksunkara authored Sep 24, 2018
2 parents 6471b54 + 242dcbd commit dd1953c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
69 changes: 34 additions & 35 deletions lib/cli/bin/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
2 changes: 1 addition & 1 deletion lib/cli/lib/initiate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit dd1953c

Please sign in to comment.