Skip to content

Commit 3edb447

Browse files
committed
Remove remove helper
1 parent 651b290 commit 3edb447

File tree

5 files changed

+7
-20
lines changed

5 files changed

+7
-20
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"url": "https://github.com/TypeStrong/TypeDoc/issues"
2222
},
2323
"engines": {
24-
"node": ">= 14"
24+
"node": ">= 14.14"
2525
},
2626
"dependencies": {
2727
"lunr": "^2.3.9",

src/lib/output/renderer.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { Theme } from "./theme";
1414
import { RendererEvent, PageEvent } from "./events";
1515
import type { ProjectReflection } from "../models/reflections/project";
1616
import type { UrlMapping } from "./models/UrlMapping";
17-
import { remove, writeFileSync } from "../utils/fs";
17+
import { writeFileSync } from "../utils/fs";
1818
import { DefaultTheme } from "./themes/default/DefaultTheme";
1919
import { RendererComponent } from "./components";
2020
import { Component, ChildableComponent } from "../utils/component";
@@ -337,7 +337,10 @@ export class Renderer extends ChildableComponent<
337337
private async prepareOutputDirectory(directory: string): Promise<boolean> {
338338
if (this.cleanOutputDir) {
339339
try {
340-
await remove(directory);
340+
await fs.promises.rm(directory, {
341+
recursive: true,
342+
force: true,
343+
});
341344
} catch (error) {
342345
this.application.logger.warn(
343346
"Could not empty the output directory."

src/lib/utils/fs.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,6 @@ export function copySync(src: string, dest: string): void {
133133
}
134134
}
135135

136-
/**
137-
* Equivalent to rm -rf
138-
* @param target
139-
*/
140-
export async function remove(target: string) {
141-
// Since v14.14
142-
if (fsp.rm) {
143-
await fsp.rm(target, { recursive: true, force: true });
144-
} else if (fs.existsSync(target)) {
145-
// Ew. We shouldn't need the exists check... Can't wait for Node 14.
146-
await fsp.rmdir(target, { recursive: true });
147-
}
148-
}
149-
150136
/**
151137
* Simpler version of `glob.sync` that only covers our use cases, only ever matching files, and ignoring node_modules.
152138
*/

src/lib/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export {
1414
getCommonDirectory,
1515
normalizePath,
1616
readFile,
17-
remove,
1817
writeFile,
1918
writeFileSync,
2019
} from "./fs";

src/test/capture-screenshots.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import * as fs from "fs";
22
import { platform } from "os";
33
import { resolve, join, dirname, relative } from "path";
44
import { Application, TSConfigReader, EntryPointStrategy } from "..";
5-
import { remove } from "../lib/utils";
65
import { glob } from "../lib/utils/fs";
76

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

7776
await captureScreenshots(baseDirectory, outputDirectory);

0 commit comments

Comments
 (0)