-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds prune script to remove unused files
- Loading branch information
Showing
8 changed files
with
33 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// List all the folder paths contained in the docs/images/previews directory | ||
import { readdirSync, readFileSync, rmSync } from "fs"; | ||
import { glob } from "glob"; | ||
|
||
const dir = "docs/images/previews"; | ||
const folders = readdirSync(dir, { withFileTypes: true }) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.map((dirent) => dirent.name); | ||
|
||
// List all the mdx files contained in the docs directory | ||
|
||
const mdxFiles = glob.sync("docs/**/*.mdx"); | ||
|
||
let unusedPreviews = folders; | ||
|
||
// For each mdx file, check if it contains a preview image | ||
mdxFiles.forEach((file) => { | ||
const content = readFileSync(file, "utf-8"); | ||
|
||
unusedPreviews = unusedPreviews.filter( | ||
(preview) => !content.includes(preview) | ||
); | ||
}); | ||
|
||
// Remove the previews that are still in the unusued | ||
unusedPreviews.forEach((preview) => { | ||
const path = `${dir}/${preview}`; | ||
rmSync(path, { recursive: true }); | ||
}); |
Binary file removed
BIN
-43.9 KB
docs/images/previews/ui-templates-nda-markdown-1a40f502/document.1.jpg
Binary file not shown.
Binary file removed
BIN
-22.1 KB
docs/images/previews/ui-templates-nda-markdown-1a40f502/document.pdf
Binary file not shown.
Binary file removed
BIN
-41 KB
docs/images/previews/ui-templates-nda-markdown-4761c826/document.1.jpg
Binary file not shown.
Binary file removed
BIN
-28.3 KB
docs/images/previews/ui-templates-nda-markdown-4761c826/document.pdf
Binary file not shown.
Binary file removed
BIN
-37.4 KB
docs/images/previews/ui-templates-nda-markdown-af102543/document.1.jpg
Binary file not shown.
Binary file not shown.
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