Skip to content

Commit 0adf4da

Browse files
committed
[DEPENDENCY] Switch from "rimraf" to native "fs.rm" (#1098)
1 parent 895fb41 commit 0adf4da

File tree

5 files changed

+84
-40
lines changed

5 files changed

+84
-40
lines changed

lib/tasks/jsdoc/generateJsdoc.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ const log = getLogger("builder:tasks:jsdoc:generateJsdoc");
33
import path from "node:path";
44
import os from "node:os";
55
import fs from "graceful-fs";
6-
import {rimraf} from "rimraf";
6+
import {mkdirp, rmrf} from "../../utils/fs.js";
77
import {promisify} from "node:util";
88
const mkdtemp = promisify(fs.mkdtemp);
9-
const mkdir = promisify(fs.mkdir);
109
import jsdocGenerator from "../../processors/jsdoc/jsdocGenerator.js";
1110
import {createAdapter} from "@ui5/fs/resourceFactory";
1211

@@ -104,19 +103,19 @@ const utils = {
104103
const tmpDirPath = await utils.createTmpDir(projectName);
105104

106105
const sourcePath = path.join(tmpDirPath, "src"); // dir will be created by writing project resources below
107-
await mkdir(sourcePath, {recursive: true});
106+
await mkdirp(sourcePath);
108107
const targetPath = path.join(tmpDirPath, "target"); // dir will be created by jsdoc itself
109-
await mkdir(targetPath, {recursive: true});
108+
await mkdirp(targetPath);
110109

111110
const tmpPath = path.join(tmpDirPath, "tmp"); // dir needs to be created by us
112-
await mkdir(tmpPath, {recursive: true});
111+
await mkdirp(tmpPath);
113112

114113
return {
115114
sourcePath,
116115
targetPath,
117116
tmpPath,
118117
cleanup: async () => {
119-
return rimraf(tmpDirPath);
118+
return rmrf(tmpDirPath);
120119
}
121120
};
122121
},
@@ -132,7 +131,7 @@ const utils = {
132131
const sanitizedProjectName = projectName.replace(/[^A-Za-z0-9]/g, "");
133132

134133
const tmpRootPath = path.join(os.tmpdir(), "ui5-tooling");
135-
await mkdir(tmpRootPath, {recursive: true});
134+
await mkdirp(tmpRootPath);
136135

137136
// Appending minus sign also because node docs advise to "avoid trailing X characters in prefix"
138137
return mkdtemp(path.join(tmpRootPath, `jsdoc-${sanitizedProjectName}-`));

lib/utils/fs.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import fs from "graceful-fs";
2+
import {promisify} from "node:util";
3+
const mkdir = promisify(fs.mkdir);
4+
const rm = promisify(fs.rm);
5+
6+
export async function mkdirp(dirPath) {
7+
return mkdir(dirPath, {recursive: true});
8+
}
9+
10+
export async function rmrf(dirPath) {
11+
return rm(dirPath, {recursive: true, force: true});
12+
}

package-lock.json

Lines changed: 45 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"version": "git-chglog --sort semver --next-tag v$npm_package_version -o CHANGELOG.md v4.0.0.. && git add CHANGELOG.md",
5151
"prepublishOnly": "git push --follow-tags",
5252
"release-note": "git-chglog --sort semver -c .chglog/release-config.yml v$npm_package_version",
53-
"depcheck": "depcheck --ignores @ui5/builder,docdash,@istanbuljs/esm-loader-hook,catharsis --parsers='**/*.js:es6,**/*.cjs:es6'"
53+
"depcheck": "depcheck --ignores @ui5/builder,docdash,@istanbuljs/esm-loader-hook,catharsis,rimraf --parsers='**/*.js:es6,**/*.cjs:es6'"
5454
},
5555
"files": [
5656
"CHANGELOG.md",
@@ -132,7 +132,6 @@
132132
"jsdoc": "^4.0.4",
133133
"less-openui5": "^0.11.6",
134134
"pretty-data": "^0.40.0",
135-
"rimraf": "^6.0.1",
136135
"semver": "^7.6.3",
137136
"terser": "^5.36.0",
138137
"workerpool": "^9.2.0",
@@ -157,6 +156,7 @@
157156
"line-column": "^1.0.2",
158157
"nyc": "^17.1.0",
159158
"open-cli": "^8.0.0",
159+
"rimraf": "^6.0.1",
160160
"sinon": "^19.0.2",
161161
"tap-xunit": "^2.4.1"
162162
}

0 commit comments

Comments
 (0)