Skip to content

Commit

Permalink
fix(cli): Fix a bug in init subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
wadackel committed Nov 1, 2020
1 parent c117497 commit 982553b
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fs from 'fs';
import path from 'path';
import { promisify } from 'util';
import type { Config } from '@acot/types';
import { shorthand2pkg } from '@acot/utils';
import chalk from 'chalk';
import enquirer from 'enquirer';
import execa from 'execa';
Expand Down Expand Up @@ -185,7 +184,7 @@ const promptUserIfNeeded = async (defaults: Partial<PromptResult>) => {
message: 'Default runner',
},
{
name: '@acot/acot-runner-storybook',
name: '@acot/storybook',
message: 'Storybook runner',
},
],
Expand Down Expand Up @@ -254,7 +253,10 @@ const result2string = (result: PromptResult) => {
}

config.origin = result.origin;
config.paths = ['/'];

if (result.runner !== '@acot/storybook') {
config.paths = ['/'];
}

const content = JSON.stringify(config, null, ' ');

Expand Down Expand Up @@ -403,20 +405,27 @@ export default createCommand({
const deps: string[] = [];

if (result.useConfig) {
deps.push(shorthand2pkg('@acot', 'config'));
deps.push('@acot/acot-config');
}

if (result.installPuppeteer) {
deps.push('puppeteer');
}

switch (result.runner) {
case 'storybook':
case '@acot/storybook':
deps.push('@acot/acot-runner-storybook');
break;
}

return execa(result.npmClient, ['install', '-D', ...deps]);
switch (result.npmClient) {
case 'npm':
return execa('npm', ['install', '-D', ...deps]);
case 'yarn':
return execa('yarn', ['add', '-D', ...deps]);
default:
throw new Error('Invalid npm client');
}
},
},
]);
Expand Down

0 comments on commit 982553b

Please sign in to comment.