mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-27 05:28:43 +02:00
fix(core): throw error if build folder already exists on initial clean (#9112)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
c8e7ce33f5
commit
8ea1945f35
1 changed files with 12 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
||||||
// More context: https://github.com/facebook/docusaurus/pull/1839
|
// More context: https://github.com/facebook/docusaurus/pull/1839
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import fs from 'fs-extra';
|
||||||
import {sync as delSync} from 'del';
|
import {sync as delSync} from 'del';
|
||||||
import type {Compiler, Stats} from 'webpack';
|
import type {Compiler, Stats} from 'webpack';
|
||||||
|
|
||||||
|
@ -152,6 +153,17 @@ export default class CleanWebpackPlugin {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
// eslint-disable-next-line no-restricted-properties
|
||||||
|
fs.pathExistsSync(this.outputPath) &&
|
||||||
|
// eslint-disable-next-line no-restricted-properties
|
||||||
|
fs.statSync(this.outputPath).isFile()
|
||||||
|
) {
|
||||||
|
throw new Error(
|
||||||
|
`A file '${this.outputPath}' already exists. Docusaurus needs this directory to save the build output. Either remove/change the file or choose a different build directory via '--out-dir'.`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
this.initialClean = true;
|
this.initialClean = true;
|
||||||
|
|
||||||
this.removeFiles(this.cleanOnceBeforeBuildPatterns);
|
this.removeFiles(this.cleanOnceBeforeBuildPatterns);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue