Skip to content

Commit

Permalink
Allow running link without starting
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeasday committed Jul 31, 2022
1 parent 9d831be commit 99d6c52
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions code/lib/cli/src/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ program
.command('link <repo-url-or-directory>')
.description('Pull down a repro from a URL (or a local directory), link it, and run storybook')
.option('--local', 'Link a local directory already in your file system')
.action((target, { local }) =>
link({ target, local }).catch((e) => {
.option('--no-start', 'Start the storybook', true)
.action((target, { local, start }) =>
link({ target, local, start }).catch((e) => {
logger.error(e);
process.exit(1);
})
Expand Down
9 changes: 6 additions & 3 deletions code/lib/cli/src/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import { exec } from './repro-generators/scripts';
interface LinkOptions {
target: string;
local?: boolean;
start: boolean;
}

export const link = async ({ target, local }: LinkOptions) => {
export const link = async ({ target, local, start }: LinkOptions) => {
const storybookDir = process.cwd();
try {
const packageJson = JSON.parse(fse.readFileSync('package.json', 'utf8'));
Expand Down Expand Up @@ -58,6 +59,8 @@ export const link = async ({ target, local }: LinkOptions) => {
);
await exec(`yarn add -D webpack-hot-middleware`, { cwd: reproDir });

logger.info(`Running ${reproName} storybook`);
await exec(`yarn run storybook`, { cwd: reproDir });
if (start) {
logger.info(`Running ${reproName} storybook`);
await exec(`yarn run storybook`, { cwd: reproDir });
}
};

0 comments on commit 99d6c52

Please sign in to comment.