Skip to content

Commit

Permalink
Remove remove helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed Jun 4, 2022
1 parent 651b290 commit 3edb447
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -21,7 +21,7 @@
"url": "https://github.com/TypeStrong/TypeDoc/issues"
},
"engines": {
"node": ">= 14"
"node": ">= 14.14"
},
"dependencies": {
"lunr": "^2.3.9",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/output/renderer.ts
Expand Up @@ -14,7 +14,7 @@ import type { Theme } from "./theme";
import { RendererEvent, PageEvent } from "./events";
import type { ProjectReflection } from "../models/reflections/project";
import type { UrlMapping } from "./models/UrlMapping";
import { remove, writeFileSync } from "../utils/fs";
import { writeFileSync } from "../utils/fs";
import { DefaultTheme } from "./themes/default/DefaultTheme";
import { RendererComponent } from "./components";
import { Component, ChildableComponent } from "../utils/component";
Expand Down Expand Up @@ -337,7 +337,10 @@ export class Renderer extends ChildableComponent<
private async prepareOutputDirectory(directory: string): Promise<boolean> {
if (this.cleanOutputDir) {
try {
await remove(directory);
await fs.promises.rm(directory, {
recursive: true,
force: true,
});
} catch (error) {
this.application.logger.warn(
"Could not empty the output directory."
Expand Down
14 changes: 0 additions & 14 deletions src/lib/utils/fs.ts
Expand Up @@ -133,20 +133,6 @@ export function copySync(src: string, dest: string): void {
}
}

/**
* Equivalent to rm -rf
* @param target
*/
export async function remove(target: string) {
// Since v14.14
if (fsp.rm) {
await fsp.rm(target, { recursive: true, force: true });
} else if (fs.existsSync(target)) {
// Ew. We shouldn't need the exists check... Can't wait for Node 14.
await fsp.rmdir(target, { recursive: true });
}
}

/**
* Simpler version of `glob.sync` that only covers our use cases, only ever matching files, and ignoring node_modules.
*/
Expand Down
1 change: 0 additions & 1 deletion src/lib/utils/index.ts
Expand Up @@ -14,7 +14,6 @@ export {
getCommonDirectory,
normalizePath,
readFile,
remove,
writeFile,
writeFileSync,
} from "./fs";
Expand Down
3 changes: 1 addition & 2 deletions src/test/capture-screenshots.ts
Expand Up @@ -2,7 +2,6 @@ import * as fs from "fs";
import { platform } from "os";
import { resolve, join, dirname, relative } from "path";
import { Application, TSConfigReader, EntryPointStrategy } from "..";
import { remove } from "../lib/utils";
import { glob } from "../lib/utils/fs";

// The @types package plays badly with non-dom packages.
Expand Down Expand Up @@ -71,7 +70,7 @@ export async function captureRegressionScreenshots() {
});
const project = app.convert();
if (!project) throw new Error("Failed to convert.");
await remove(outputDirectory);
await fs.promises.rm(outputDirectory, { recursive: true, force: true });
await app.generateDocs(project, baseDirectory);

await captureScreenshots(baseDirectory, outputDirectory);
Expand Down

0 comments on commit 3edb447

Please sign in to comment.