-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(v2): new docusaurus clear command (#3446)
* feat: new docusaurus clear command * Update packages/docusaurus/bin/docusaurus.js Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com> * docs: new docusaurus clear command * fix doc * update monorepo clear cmd * make clear async function wait for deletes to complete + factorize a bit * prettier fix * better clear docs Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com> Co-authored-by: slorber <lorber.sebastien@gmail.com> Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
- Loading branch information
1 parent
06cc8fb
commit cc31567
Showing
6 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
import fs from 'fs-extra'; | ||
import path from 'path'; | ||
import chalk = require('chalk'); | ||
import {BUILD_DIR_NAME, GENERATED_FILES_DIR_NAME} from '../constants'; | ||
|
||
function removePath(fsPath: string) { | ||
return fs | ||
.remove(path.join(fsPath)) | ||
.then(() => { | ||
console.log(`${chalk.green(`Removing ${fsPath}`)}`); | ||
}) | ||
.catch((err) => { | ||
console.error(`Could not remove ${fsPath}`); | ||
console.error(err); | ||
}); | ||
} | ||
|
||
export default async function clear(siteDir: string): Promise<unknown> { | ||
return Promise.all([ | ||
removePath(path.join(siteDir, GENERATED_FILES_DIR_NAME)), | ||
removePath(path.join(siteDir, BUILD_DIR_NAME)), | ||
removePath(path.join(siteDir, 'node_modules/.cache/cache-loader')), | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters