Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): throw error if build folder already exists on initial clean #9112

Merged
merged 13 commits into from
Jun 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
// More context: https://github.com/facebook/docusaurus/pull/1839

import path from 'path';
import * as fs from 'fs';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use fs-extra and await fs.pathExists(); you can find other examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Josh-Cena I'm pushing a commit that use await pathExists instead of sync func

import {sync as delSync} from 'del';
import type {Compiler, Stats} from 'webpack';

Expand Down Expand Up @@ -153,8 +154,8 @@ export default class CleanWebpackPlugin {
}

if (
path.basename(path.resolve()).toLowerCase() ===
path.basename(path.resolve(this.outputPath)).toLowerCase()
// eslint-disable-next-line no-restricted-properties
fs.existsSync(this.outputPath)
) {
throw new Error(
'output dir already exist. Docusaurus needs this directory to save the output build. Either remove your directory or chose a different build directory',
Josh-Cena marked this conversation as resolved.
Show resolved Hide resolved
Expand Down