Skip to content

Commit

Permalink
chore: remove fs-extra
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoishin committed Dec 26, 2024
1 parent e635a07 commit a35d795
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 63 deletions.
45 changes: 0 additions & 45 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 @@ -34,7 +34,6 @@
"dependencies": {
"chalk": "3.0.0",
"commander": "^6.1.0",
"fs-extra": "7.0.1",
"inquirer": "^7.3.3",
"json-schema-defaults": "0.4.0",
"json-schema-to-typescript": "11.0.3",
Expand All @@ -47,7 +46,6 @@
"devDependencies": {
"@eslint/js": "^9.17.0",
"@gamesdonequick/prettier-config": "^2.2.1",
"@types/fs-extra": "5.0.4",
"@types/hosted-git-info": "2.7.0",
"@types/inquirer": "^7.3.1",
"@types/node": "18",
Expand Down
3 changes: 1 addition & 2 deletions src/commands/schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { promisify } from "node:util";

import chalk from "chalk";
import { Command } from "commander";
import fse from "fs-extra";
import { compileFromFile } from "json-schema-to-typescript";

const writeFilePromise = promisify(fs.writeFile);
Expand Down Expand Up @@ -40,7 +39,7 @@ function action(inDir: string, cmd: { outDir: string; configSchema: boolean }) {

const outDir = path.resolve(processCwd, cmd.outDir);
if (!fs.existsSync(outDir)) {
fse.mkdirpSync(outDir);
fs.mkdirSync(outDir, { recursive: true });
}

const configSchemaPath = path.join(processCwd, "configschema.json");
Expand Down
22 changes: 12 additions & 10 deletions test/commands/defaultconfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fs from "node:fs";
import path from "node:path";

import { Command } from "commander";
import fse from "fs-extra";
import { beforeEach, describe, expect, it, vi } from "vitest";

import defaultConfigCommand from "../../src/commands/defaultconfig";
Expand All @@ -18,7 +17,7 @@ beforeEach(() => {
fs.writeFileSync("package.json", JSON.stringify({ name: "nodecg" }));

// Copy fixtures.
fse.copySync(path.resolve(__dirname, "../fixtures/"), "./");
fs.cpSync(path.resolve(__dirname, "../fixtures/"), "./", { recursive: true });

// Build program.
program = createMockProgram();
Expand All @@ -29,7 +28,7 @@ describe("when run with a bundle argument", () => {
it("should successfully create a bundle config file when bundle has configschema.json", async () => {
await program.runWith("defaultconfig config-schema");
const config = JSON.parse(
fs.readFileSync("./cfg/config-schema.json", { encoding: "utf8" }),
fs.readFileSync("./cfg/config-schema.json", { encoding: "utf8" })
);
expect(config.username).toBe("user");
expect(config.value).toBe(5);
Expand All @@ -38,12 +37,13 @@ describe("when run with a bundle argument", () => {

it("should print an error when the target bundle does not have a configschema.json", async () => {
const spy = vi.spyOn(console, "error");
fse.mkdirpSync(
fs.mkdirSync(
path.resolve(process.cwd(), "./bundles/missing-schema-bundle"),
{ recursive: true }
);
await program.runWith("defaultconfig missing-schema-bundle");
expect(spy.mock.calls[0][0]).toMatchInlineSnapshot(
`"Error: Bundle %s does not have a configschema.json"`,
`"Error: Bundle %s does not have a configschema.json"`
);
spy.mockRestore();
});
Expand All @@ -52,7 +52,7 @@ describe("when run with a bundle argument", () => {
const spy = vi.spyOn(console, "error");
await program.runWith("defaultconfig not-installed");
expect(spy.mock.calls[0][0]).toMatchInlineSnapshot(
`"Error: Bundle %s does not exist"`,
`"Error: Bundle %s does not exist"`
);
spy.mockRestore();
});
Expand All @@ -62,11 +62,11 @@ describe("when run with a bundle argument", () => {
fs.mkdirSync("./cfg");
fs.writeFileSync(
"./cfg/config-schema.json",
JSON.stringify({ fake: "data" }),
JSON.stringify({ fake: "data" })
);
await program.runWith("defaultconfig config-schema");
expect(spy.mock.calls[0][0]).toMatchInlineSnapshot(
`"Error: Bundle %s already has a config file"`,
`"Error: Bundle %s already has a config file"`
);
spy.mockRestore();
});
Expand All @@ -80,13 +80,15 @@ describe("when run with no arguments", () => {
});

it("should print an error when in a folder with no package.json", async () => {
fse.mkdirpSync(path.resolve(process.cwd(), "./bundles/not-a-bundle"));
fs.mkdirSync(path.resolve(process.cwd(), "./bundles/not-a-bundle"), {
recursive: true,
});
process.chdir("./bundles/not-a-bundle");

const spy = vi.spyOn(console, "error");
await program.runWith("defaultconfig");
expect(spy.mock.calls[0][0]).toMatchInlineSnapshot(
`"Error: No bundle found in the current directory!"`,
`"Error: No bundle found in the current directory!"`
);
spy.mockRestore();
});
Expand Down
3 changes: 1 addition & 2 deletions test/commands/schema-types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { EventEmitter } from "node:events";
import fs from "node:fs";
import path from "node:path";

import fse from "fs-extra";
import { beforeEach, expect, it, vi } from "vitest";

import schemaTypesCommand from "../../src/commands/schema-types";
Expand All @@ -18,7 +17,7 @@ beforeEach(() => {
fs.writeFileSync("package.json", JSON.stringify({ name: "nodecg" }));

// Copy fixtures.
fse.copySync(path.resolve(__dirname, "../fixtures/"), "./");
fs.cpSync(path.resolve(__dirname, "../fixtures/"), "./", { recursive: true });

// Build program.
program = createMockProgram();
Expand Down
3 changes: 1 addition & 2 deletions test/commands/uninstall.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import fs from "node:fs";
import path from "node:path";

import { Command } from "commander";
import fse from "fs-extra";
import inquirer from "inquirer";
import { beforeEach, expect, it, vi } from "vitest";

Expand All @@ -19,7 +18,7 @@ beforeEach(() => {
fs.writeFileSync("package.json", JSON.stringify({ name: "nodecg" }));

// Copy fixtures.
fse.copySync(path.resolve(__dirname, "../fixtures/"), "./");
fs.cpSync(path.resolve(__dirname, "../fixtures/"), "./", { recursive: true });

// Build program.
program = createMockProgram();
Expand Down

0 comments on commit a35d795

Please sign in to comment.