Skip to content

Commit 76f3f47

Browse files
authored
Remove use of fs-extra (microsoft#55468)
1 parent 3a22d3a commit 76f3f47

File tree

3 files changed

+14
-109
lines changed

3 files changed

+14
-109
lines changed

package-lock.json

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

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"@esfx/canceltoken": "^1.0.0",
4343
"@octokit/rest": "^19.0.13",
4444
"@types/chai": "^4.3.4",
45-
"@types/fs-extra": "^9.0.13",
4645
"@types/glob": "^8.1.0",
4746
"@types/microsoft__typescript-etw": "^0.1.1",
4847
"@types/minimist": "^1.2.2",
@@ -68,7 +67,6 @@
6867
"eslint-plugin-no-null": "^1.0.2",
6968
"eslint-plugin-simple-import-sort": "^10.0.0",
7069
"fast-xml-parser": "^4.0.11",
71-
"fs-extra": "^9.1.0",
7270
"glob": "^8.1.0",
7371
"hereby": "^1.6.4",
7472
"jsonc-parser": "^3.2.0",

scripts/produceLKG.mjs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import fs from "fs-extra";
1+
import fs from "fs";
22
import glob from "glob";
33
import path from "path";
44
import url from "url";
@@ -16,8 +16,8 @@ const dest = path.join(root, "lib");
1616

1717
async function produceLKG() {
1818
console.log(`Building LKG from ${source} to ${dest}`);
19-
await (fs.rm || fs.rmdir)(dest, { recursive: true, force: true });
20-
await fs.mkdirp(dest);
19+
await fs.promises.rm(dest, { recursive: true, force: true });
20+
await fs.promises.mkdir(dest, { recursive: true });
2121
await copyLibFiles();
2222
await copyLocalizedDiagnostics();
2323
await copyTypesMap();
@@ -32,9 +32,15 @@ async function copyLibFiles() {
3232

3333
async function copyLocalizedDiagnostics() {
3434
for (const d of localizationDirectories) {
35-
const fileName = path.join(source, d);
36-
if (fs.statSync(fileName).isDirectory()) {
37-
await fs.copy(fileName, path.join(dest, d));
35+
const inputDir = path.join(source, d);
36+
if (!fs.statSync(inputDir).isDirectory()) throw new Error(`Expected ${inputDir} to be a directory`);
37+
const outputDir = path.join(dest, d);
38+
await fs.promises.mkdir(outputDir, { recursive: true });
39+
for (const f of await fs.promises.readdir(inputDir)) {
40+
const inputFile = path.join(inputDir, f);
41+
if (!fs.statSync(inputFile).isFile()) throw new Error(`Expected ${inputFile} to be a file`);
42+
const outputFile = path.join(outputDir, f);
43+
await fs.promises.copyFile(inputFile, outputFile);
3844
}
3945
}
4046
}
@@ -59,14 +65,14 @@ async function copyDeclarationOutputs() {
5965
}
6066

6167
async function writeGitAttributes() {
62-
await fs.writeFile(path.join(dest, ".gitattributes"), `* text eol=lf`, "utf-8");
68+
await fs.promises.writeFile(path.join(dest, ".gitattributes"), `* text eol=lf`, "utf-8");
6369
}
6470

6571
/**
6672
* @param {string} fileName
6773
*/
6874
async function copyFromBuiltLocal(fileName) {
69-
await fs.copy(path.join(source, fileName), path.join(dest, fileName));
75+
await fs.promises.copyFile(path.join(source, fileName), path.join(dest, fileName));
7076
}
7177

7278
/**

0 commit comments

Comments
 (0)