Skip to content

Commit 6ce2b8a

Browse files
authored
fix: --no-dir-check (#790)
Don't check `.git` inside the folder if the folder doesn't exist
1 parent 70255d6 commit 6ce2b8a

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

packages/addons/_tests/storybook/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const CI = Boolean(process.env.CI);
1818
beforeAll(() => {
1919
if (CI) {
2020
// prefetch the storybook cli during ci to reduce fetching errors in tests
21-
execSync('pnpx create-storybook@latest --version');
21+
execSync('pnpm dlx create-storybook@latest --version');
2222
}
2323
});
2424

packages/cli/commands/create.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,19 @@ async function createProject(cwd: ProjectPath, options: Options) {
142142
});
143143
},
144144
force: async ({ results: { directory } }) => {
145-
const directoryExists = fs.existsSync(directory!);
146-
const hasNonIgnoredFiles =
147-
fs.readdirSync(directory!).filter((x) => !x.startsWith('.git')).length > 0;
148-
if (directoryExists && hasNonIgnoredFiles && options.dirCheck) {
149-
const force = await p.confirm({
150-
message: 'Directory not empty. Continue?',
151-
initialValue: false
152-
});
153-
if (p.isCancel(force) || !force) {
154-
p.cancel('Exiting.');
155-
process.exit(0);
156-
}
145+
if (!options.dirCheck) return;
146+
147+
const files = fs.readdirSync(directory!);
148+
const hasNonIgnoredFiles = files.some((file) => !file.startsWith('.git'));
149+
if (!hasNonIgnoredFiles) return;
150+
151+
const force = await p.confirm({
152+
message: 'Directory not empty. Continue?',
153+
initialValue: false
154+
});
155+
if (p.isCancel(force) || !force) {
156+
p.cancel('Exiting.');
157+
process.exit(0);
157158
}
158159
},
159160
template: () => {

0 commit comments

Comments
 (0)