Skip to content

Commit 0d694cf

Browse files
committed
cli:refactory & fixes
1 parent ebd4509 commit 0d694cf

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

packages/storybook-nuxt-cli/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ program
1414
.option('-c, --ci', 'Run in CI mode') // avoid interactive prompts and browser opening
1515
.action(async (options) => {
1616
// if current directory is empty, create a new project
17+
1718
const nuxt = await initNuxt().catch(() => null)
1819
if (nuxt)
1920
initStorybook(Boolean(options.start), options.port, options.ci, Boolean(options.enableModule))

packages/storybook-nuxt-cli/src/init.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ async function initStorybook(start = false, port = 6006, ci = true, enableModule
8282
}
8383

8484
addDevDependencies()
85-
if (!enableModule)
85+
consola.info('🔌 enableModule ', enableModule)
86+
if (enableModule)
8687
addModuleToNuxtConfigFile('@nuxtjs/storybook', projectRoot)
8788
// Install required packages using pnpm
8889
const installProcess = spawn(packageManager, ['install'], {
@@ -236,6 +237,11 @@ async function getPackageDir(frameworkPackageName) {
236237
}
237238

238239
async function initNuxtProject() {
240+
const isEmpty = readdirSync(process.cwd()).length === 0
241+
if (!isEmpty) {
242+
logger.error(' Directory is not empty')
243+
return true
244+
}
239245
const startProcess = spawn('npx', ['nuxi', 'init', '.'], {
240246
cwd: process.cwd(),
241247
stdio: 'inherit',

pnpm-lock.yaml

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)