Skip to content

Commit

Permalink
Remove use of fs-extra (microsoft#55468)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakebailey authored Aug 23, 2023
1 parent 3a22d3a commit 76f3f47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 109 deletions.
99 changes: 0 additions & 99 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"@esfx/canceltoken": "^1.0.0",
"@octokit/rest": "^19.0.13",
"@types/chai": "^4.3.4",
"@types/fs-extra": "^9.0.13",
"@types/glob": "^8.1.0",
"@types/microsoft__typescript-etw": "^0.1.1",
"@types/minimist": "^1.2.2",
Expand All @@ -68,7 +67,6 @@
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-simple-import-sort": "^10.0.0",
"fast-xml-parser": "^4.0.11",
"fs-extra": "^9.1.0",
"glob": "^8.1.0",
"hereby": "^1.6.4",
"jsonc-parser": "^3.2.0",
Expand Down
22 changes: 14 additions & 8 deletions scripts/produceLKG.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fs from "fs-extra";
import fs from "fs";
import glob from "glob";
import path from "path";
import url from "url";
Expand All @@ -16,8 +16,8 @@ const dest = path.join(root, "lib");

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

async function copyLocalizedDiagnostics() {
for (const d of localizationDirectories) {
const fileName = path.join(source, d);
if (fs.statSync(fileName).isDirectory()) {
await fs.copy(fileName, path.join(dest, d));
const inputDir = path.join(source, d);
if (!fs.statSync(inputDir).isDirectory()) throw new Error(`Expected ${inputDir} to be a directory`);
const outputDir = path.join(dest, d);
await fs.promises.mkdir(outputDir, { recursive: true });
for (const f of await fs.promises.readdir(inputDir)) {
const inputFile = path.join(inputDir, f);
if (!fs.statSync(inputFile).isFile()) throw new Error(`Expected ${inputFile} to be a file`);
const outputFile = path.join(outputDir, f);
await fs.promises.copyFile(inputFile, outputFile);
}
}
}
Expand All @@ -59,14 +65,14 @@ async function copyDeclarationOutputs() {
}

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

/**
* @param {string} fileName
*/
async function copyFromBuiltLocal(fileName) {
await fs.copy(path.join(source, fileName), path.join(dest, fileName));
await fs.promises.copyFile(path.join(source, fileName), path.join(dest, fileName));
}

/**
Expand Down

0 comments on commit 76f3f47

Please sign in to comment.