Skip to content

Commit

Permalink
fix: remove __dirname (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hoishin authored Dec 26, 2024
1 parent a2ee285 commit 8c9a033
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ process.title = "nodecg";

import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

import chalk from "chalk";
import { Command } from "commander";
Expand All @@ -10,8 +11,9 @@ import semver from "semver";
import util from "./lib/util.js";

const program = new Command("nodecg");
const dirname = path.dirname(fileURLToPath(import.meta.url));
const packageVersion: string = JSON.parse(
fs.readFileSync(path.join(__dirname, "../package.json"), "utf8"),
fs.readFileSync(path.join(dirname, "../package.json"), "utf8"),
);

// Check for updates, asynchronously, so as to not make the CLI startup time excessively slow
Expand Down
5 changes: 4 additions & 1 deletion test/commands/defaultconfig.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

import { Command } from "commander";
import { beforeEach, describe, expect, it, vi } from "vitest";
Expand All @@ -8,6 +9,8 @@ import { defaultconfigCommand } from "../../src/commands/defaultconfig.js";
import { createMockProgram, MockCommand } from "../mocks/program.js";
import { setupTmpDir } from "./tmp-dir.js";

const dirname = path.dirname(fileURLToPath(import.meta.url));

let program: MockCommand;

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

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

// Build program.
program = createMockProgram();
Expand Down
5 changes: 4 additions & 1 deletion test/commands/schema-types.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { EventEmitter } from "node:events";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

import { beforeEach, expect, it, vi } from "vitest";

import { schemaTypesCommand } from "../../src/commands/schema-types.js";
import { createMockProgram, MockCommand } from "../mocks/program.js";
import { setupTmpDir } from "./tmp-dir.js";

const dirname = path.dirname(fileURLToPath(import.meta.url));

let program: MockCommand;

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

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

// Build program.
program = createMockProgram();
Expand Down
5 changes: 4 additions & 1 deletion test/commands/uninstall.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";

import { Command } from "commander";
import inquirer from "inquirer";
Expand All @@ -9,6 +10,8 @@ import { uninstallCommand } from "../../src/commands/uninstall.js";
import { createMockProgram, MockCommand } from "../mocks/program.js";
import { setupTmpDir } from "./tmp-dir.js";

const dirname = path.dirname(fileURLToPath(import.meta.url));

let program: MockCommand;

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

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

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

0 comments on commit 8c9a033

Please sign in to comment.