mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-15 00:05:35 +08:00
Add two additional CLI commands to storybook CLI
This commit is contained in:
parent
7d2259e569
commit
8d4805aad5
18
app/react-native/src/bin/storybook-start.js
vendored
18
app/react-native/src/bin/storybook-start.js
vendored
@ -17,6 +17,8 @@ program
|
||||
.option('-i, --manual-id', 'allow multiple users to work with same storybook')
|
||||
.option('--smoke-test', 'Exit after successful start')
|
||||
.option('--packager-port <packagerPort>', 'Custom packager port')
|
||||
.option('--root [root]', 'Add additional root(s) to be used by the packager in this project')
|
||||
.option('--projectRoots [projectRoots]', 'Override the root(s) to be used by the packager')
|
||||
.parse(process.argv);
|
||||
|
||||
const projectDir = path.resolve();
|
||||
@ -48,6 +50,12 @@ server.listen(...listenAddr, err => {
|
||||
if (!program.skipPackager) {
|
||||
let symlinks = [];
|
||||
|
||||
let roots = [projectDir];
|
||||
|
||||
if (program.root) {
|
||||
roots = roots.concat(program.root.split(',').map(root => path.resolve(root)));
|
||||
}
|
||||
|
||||
try {
|
||||
const findSymlinksPaths = require('react-native/local-cli/util/findSymlinksPaths'); // eslint-disable-line global-require
|
||||
symlinks = findSymlinksPaths(path.join(projectDir, 'node_modules'), [projectDir]);
|
||||
@ -55,10 +63,16 @@ if (!program.skipPackager) {
|
||||
console.warn(`Unable to load findSymlinksPaths: ${e.message}`);
|
||||
}
|
||||
|
||||
const projectRoots = (configDir === projectDir ? [configDir] : [configDir, projectDir]).concat(
|
||||
let projectRoots = (configDir === projectDir ? [configDir] : [configDir, projectDir]).concat(
|
||||
symlinks
|
||||
);
|
||||
|
||||
if (program.projectRoots) {
|
||||
projectRoots = projectRoots.concat(
|
||||
program.projectRoots.split(',').map(root => path.resolve(root))
|
||||
);
|
||||
}
|
||||
|
||||
let cliCommand = 'node node_modules/react-native/local-cli/cli.js start';
|
||||
if (program.haul) {
|
||||
cliCommand = `node node_modules/.bin/haul start --config ${program.haul} --platform all`;
|
||||
@ -68,7 +82,7 @@ if (!program.skipPackager) {
|
||||
[
|
||||
cliCommand,
|
||||
`--projectRoots ${projectRoots.join(',')}`,
|
||||
`--root ${projectDir}`,
|
||||
`--root ${roots.join(',')}`,
|
||||
program.resetCache && '--reset-cache',
|
||||
program.packagerPort && `--port=${program.packagerPort}`,
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user