Skip to content

Commit

Permalink
refactor: Remove fs-extra
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit0 committed May 1, 2021
1 parent a446431 commit 5ffe73d
Show file tree
Hide file tree
Showing 18 changed files with 343 additions and 345 deletions.
46 changes: 19 additions & 27 deletions .eslintrc
@@ -1,6 +1,9 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json"
},
"env": {
"node": true,
"es6": true
Expand All @@ -11,8 +14,23 @@
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"ignorePatterns": ["src/test/renderer/specs/**", "examples/**", "dist"],
"ignorePatterns": [
"src/test/renderer/specs",
"examples",
"dist",
"coverage",
// Would be nice to lint these, but they shouldn't be included in the project,
// so we need a second eslint config file.
"src/test/converter",
"src/test/converter2",
"src/test/module",
"src/test/renderer",
"scripts",
"bin"
],
"rules": {
"@typescript-eslint/no-floating-promises": 1,

// This rule is factually incorrect. Interfaces which extend some type alias can be used to introduce
// new type names. This is useful particularly when dealing with mixins.
"@typescript-eslint/no-empty-interface": 0,
Expand Down Expand Up @@ -40,32 +58,6 @@
]
},
"overrides": [
{
"files": [
"src/test/converter/**",
"src/test/converter2/**",
"src/test/renderer/**"
],
"rules": {
"prefer-rest-params": 0,
"no-inner-declarations": 0,
"no-var": 0,
"prefer-const": 0,
"@typescript-eslint/prefer-namespace-keyword": 0,
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-unused-vars": 0,
"@typescript-eslint/no-misused-new": 0
}
},
{
"files": ["scripts/**", "bin/typedoc.js"],
"rules": {
// We don't depend on a new enough version of node to use imports here...
"@typescript-eslint/no-var-requires": 0
}
},
{
"files": ["src/test/**"],
"env": {
Expand Down
89 changes: 23 additions & 66 deletions package-lock.json

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

7 changes: 2 additions & 5 deletions package.json
Expand Up @@ -21,7 +21,6 @@
},
"dependencies": {
"colors": "^1.4.0",
"fs-extra": "^9.1.0",
"handlebars": "^4.7.7",
"lodash": "^4.17.21",
"lunr": "^2.3.9",
Expand All @@ -36,19 +35,17 @@
"typescript": "3.9.x || 4.0.x || 4.1.x || 4.2.x"
},
"devDependencies": {
"@types/fs-extra": "^9.0.11",
"@types/lodash": "^4.14.168",
"@types/lunr": "^2.3.3",
"@types/marked": "^2.0.2",
"@types/minimatch": "3.0.4",
"@types/mocha": "^8.2.2",
"@types/mockery": "^1.4.29",
"@types/node": "^14.14.41",
"@types/semver": "^7.3.4",
"@types/node": "^15.0.1",
"@types/shelljs": "^0.8.8",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.22.0",
"eslint": "^7.24.0",
"eslint": "^7.25.0",
"mocha": "^8.3.2",
"mockery": "^2.1.0",
"nyc": "^15.1.0",
Expand Down
12 changes: 5 additions & 7 deletions scripts/copy_test_files.js
@@ -1,23 +1,21 @@
// @ts-check

const fs = require("fs-extra");
const { remove, copy } = require("../dist/lib/utils/fs");
const { join } = require("path");

const copy = [
const toCopy = [
"test/converter",
"test/converter2",
"test/renderer",
"test/module",
"test/utils/options/readers/data",
];

const copies = copy.map((dir) => {
const copies = toCopy.map(async (dir) => {
const source = join(__dirname, "../src", dir);
const target = join(__dirname, "../dist", dir);
return fs
.remove(target)
.then(() => fs.mkdirp(target))
.then(() => fs.copy(source, target));
await remove(target);
await copy(source, target);
});

Promise.all(copies).catch((reason) => {
Expand Down
17 changes: 9 additions & 8 deletions scripts/rebuild_specs.js
@@ -1,8 +1,9 @@
"use strict";
// @ts-check
"use strict";

const ts = require("typescript");
const fs = require("fs-extra");
const fs = require("fs");
const { remove } = require("../dist/lib/utils/fs");
const path = require("path");
const TypeDoc = require("..");

Expand Down Expand Up @@ -89,10 +90,10 @@ function rebuildConverterTests(dirs) {
}

async function rebuildRendererTest() {
await fs.remove(path.join(__dirname, "../src/test/renderer/specs"));
await remove(path.join(__dirname, "../src/test/renderer/specs"));
const src = path.join(__dirname, "../examples/basic/src");
const out = path.join(__dirname, "../src/test/renderer/specs");
await fs.remove(out);
await remove(out);

const app = new TypeDoc.Application();
app.options.addReader(new TypeDoc.TSConfigReader());
Expand Down Expand Up @@ -132,10 +133,10 @@ async function rebuildRendererTest() {
const gitHubRegExp = /https:\/\/github.com\/[A-Za-z0-9-]+\/typedoc\/blob\/[^/]*\/examples/g;
return getFiles(out).map((file) => {
const full = path.join(out, file);
return fs
return fs.promises
.readFile(full, { encoding: "utf-8" })
.then((text) =>
fs.writeFile(
fs.promises.writeFile(
full,
text.replace(
gitHubRegExp,
Expand All @@ -156,9 +157,9 @@ async function main(command = "all", filter = "") {

if (["all", "converter"].includes(command)) {
const dirs = await Promise.all(
(await fs.readdir(base)).map((dir) => {
(await fs.promises.readdir(base)).map((dir) => {
const dirPath = path.join(base, dir);
return Promise.all([dirPath, fs.stat(dirPath)]);
return Promise.all([dirPath, fs.promises.stat(dirPath)]);
})
);

Expand Down
6 changes: 3 additions & 3 deletions scripts/set_strict.js
@@ -1,11 +1,11 @@
// @ts-check
// Sets the Strict type that TypeDoc uses to enable overloads for consumers only.
// See the rationale in src/lib/utils/index.ts
// See the rationale in src/lib/utils/general.ts

const fs = require("fs-extra");
const { promises: fs } = require("fs");
const { join } = require("path");

const file = join(__dirname, "../src/lib/utils/index.ts");
const file = join(__dirname, "../src/lib/utils/general.ts");

const isStrict = process.argv[2] === "true";

Expand Down

0 comments on commit 5ffe73d

Please sign in to comment.