Skip to content

Commit

Permalink
fix: remove dirname in source files
Browse files Browse the repository at this point in the history
  • Loading branch information
Romakita committed Sep 28, 2024
1 parent 953c5b1 commit 4e4f4e2
Show file tree
Hide file tree
Showing 48 changed files with 50 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {$log} from "@tsed/common";
import {PlatformExpress} from "@tsed/platform-express";
import {Server} from "./server";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname;

// /!\ configuration file must be outside of your src directory
process.env["NODE_CONFIG_DIR"] = `${rootDir}/../config`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Get} from "@tsed/schema";
import {createReadStream, ReadStream} from "fs";
import {Observable, of} from "rxjs";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname;

@Controller("/")
export class KindOfResponseCtrl {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/domain/AnyToPromise.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {catchAsyncError} from "../utils/catchError.js";
import {isStream} from "../utils/objects/isStream.js";
import {AnyToPromise, AnyToPromiseStatus} from "./AnyToPromise.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

describe("AnyToPromise", () => {
it("should handle sync value", async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/engines/src/utils/getEngines.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {join} from "path";

import {getEngine, getEngines} from "./getEngines.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

describe("getEngines", () => {
describe("getEngine()", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/engines/test/getEngineFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from "fs";
import {Engine} from "../src/components/Engine.js";
import {engines} from "../src/index.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

interface EngineFixtureOptions {
token: string | typeof Engine;
Expand Down
2 changes: 1 addition & 1 deletion packages/engines/test/shared/dust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {join} from "path";

import {engines, requires} from "../../src/index.js";

const rootDir = join(__dirname, "..");
const rootDir = join(import.meta.dirname, "..");

export function test(name: string) {
const user = {name: "Tobi"};
Expand Down
2 changes: 1 addition & 1 deletion packages/engines/test/shared/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {join} from "path";

import {engines} from "../../src/index.js";

const rootDir = join(__dirname, "..");
const rootDir = join(import.meta.dirname, "..");

export function test(name: string) {
const engine = engines.get(name)!;
Expand Down
2 changes: 1 addition & 1 deletion packages/engines/test/shared/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {engines} from "../../src/index.js";

const Sqrl = require("squirrelly");

const rootDir = join(__dirname, "..");
const rootDir = join(import.meta.dirname, "..");

const readFile = fs.readFile;
const readFileSync = fs.readFileSync;
Expand Down
2 changes: 1 addition & 1 deletion packages/engines/test/shared/includes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {join} from "path";

import {engines} from "../../src/index.js";

const rootDir = join(__dirname, "..");
const rootDir = join(import.meta.dirname, "..");

export function test(name: string) {
const engine = engines.get(name)!;
Expand Down
2 changes: 1 addition & 1 deletion packages/engines/test/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {join} from "path";

import {engines, requires} from "../../src/index.js";

const rootDir = join(__dirname, "..");
const rootDir = join(import.meta.dirname, "..");

const readFile = fs.readFile;
const readFileSync = fs.readFileSync;
Expand Down
4 changes: 2 additions & 2 deletions packages/engines/test/shared/partials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {join} from "path";

import {engines} from "../../src/index.js";

const rootDir = join(__dirname, "..");
const rootDir = join(import.meta.dirname, "..");

const readFile = fs.readFile;
const readFileSync = fs.readFileSync;
Expand Down Expand Up @@ -38,7 +38,7 @@ export function test(name: string) {
});
it("should support absolute path partial", async () => {
const path = `${rootDir}/fixtures/${name}/partials.${name}`;
const locals = {user: user, partials: {partial: join(__dirname, "/../../test/fixtures/", name, "/user")}};
const locals = {user: user, partials: {partial: join(import.meta.dirname, "/../../test/fixtures/", name, "/user")}};
const html = await engine.renderFile(path, locals);
expect(html).toEqual("<p>Tobi</p>");
});
Expand Down
2 changes: 1 addition & 1 deletion packages/engines/test/shared/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {join} from "path";

import {engines} from "../../src/index.js";

const rootDir = join(__dirname, "..");
const rootDir = join(import.meta.dirname, "..");

const readFile = fs.readFile;
const readFileSync = fs.readFileSync;
Expand Down
2 changes: 1 addition & 1 deletion packages/graphql/typegraphql/test/app/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {User} from "./graphql/auth/User.js";
import {AuthResolver} from "./graphql/index.js";
import {pubSub} from "./graphql/pubsub/pubsub.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build
const rootCert = join(rootDir, "../..");
@Configuration({
rootDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/mikro-orm/test/helpers/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import compress from "compression";
import cookieParser from "cookie-parser";
import methodOverride from "method-override";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

@Configuration({
rootDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/mongoose/test/helpers/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import compress from "compression";
import cookieParser from "cookie-parser";
import methodOverride from "method-override";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

@Configuration({
rootDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/objection/test/helpers/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import compress from "compression";
import cookieParser from "cookie-parser";
import methodOverride from "method-override";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

@Configuration({
rootDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/objection/test/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {afterAll, beforeAll, beforeEach, describe, expect, it} from "vitest";
import {OBJECTION_CONNECTION} from "..";
import {User} from "./helpers/models/User.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

describe.skip("Objection integrations", () => {
beforeAll(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/orm/prisma/src/__mock__/createProjectFixture.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {join} from "path";
import {ModuleKind, Project, ScriptTarget} from "ts-morph";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

const SNAPSHOT_DIR = `${rootDir}/../../test/snapshots`;

Expand Down
2 changes: 1 addition & 1 deletion packages/orm/prisma/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {join} from "path";

import {generate} from "./cli/prismaGenerator.js";

const rootDir = __dirname; // automatically replaced by tsed tools on build
const rootDir = import.meta.dirname; // automatically replaced by tsed tools on build
export const defaultOutput = join(rootDir, "..", ".schema");
export const packageDir = join(rootDir, "..", "..");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {createReadStream} from "fs";
import {PlatformResponse} from "./PlatformResponse.js";
import {PlatformTest} from "./PlatformTest.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

vi.mock("on-finished");

Expand Down
2 changes: 1 addition & 1 deletion packages/platform/common/test/integration/groups.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SuperTest from "supertest";

import {BodyParams, Configuration, Controller, Get, PlatformTest} from "../../src/index.ts";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

class MyModel {
@Groups("!creation")
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/common/test/integration/platform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SuperTest from "supertest";

import {Configuration, Controller, Get, PlatformTest} from "../../src/index.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

@Controller("/hello")
class TestHelloWorld {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {getJsonSchema, getSpec, OperationPath, Path, Returns, SpecTypes} from "@
import {Ajv} from "ajv";
import fs from "fs-extra";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

function getAjv() {
return new Ajv({
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/platform-express/test/app/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import compress from "compression";
import {Application} from "express";
import session from "express-session";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build
export {rootDir};

@Configuration({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import SuperTest from "supertest";
import {PlatformExpress} from "../src/index.js";
import {rootDir, Server} from "./app/Server.js";

const root = __dirname;
const root = import.meta.dirname;

const utils = PlatformTestSdk.create({
rootDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/platform/platform-koa/test/app/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Configuration, Inject} from "@tsed/di";
import Application from "koa";
import session from "koa-session";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build
export {rootDir};

@Configuration({
Expand Down
4 changes: 2 additions & 2 deletions packages/platform/platform-test-sdk/src/tests/testMulter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {afterAll, beforeAll, describe, expect, it, vi} from "vitest";

import {PlatformTestingSdkOpts} from "../interfaces/index.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

export class Task {
@Property()
Expand Down Expand Up @@ -80,7 +80,7 @@ export function testMulter(options: PlatformTestingSdkOpts) {
const buffer = Buffer.from("test content");

const pkg = readPkgUp.sync({
cwd: __dirname
cwd: import.meta.dirname
});
const rootDir = join(dirname(pkg?.path || ""), "src");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {afterAll, beforeAll, describe, expect, it} from "vitest";

import {PlatformTestingSdkOpts} from "../interfaces/index.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

@Controller("/stream")
class TestStreamCtrl {
Expand Down
2 changes: 1 addition & 1 deletion packages/security/jwks/src/getJwks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {join} from "path";

import {generateJwks, getJwks} from "./getJwks.js";

const rootDir = join(__dirname, "__mocks__");
const rootDir = join(import.meta.dirname, "__mocks__");

describe("GetJwks", () => {
beforeEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion packages/security/oidc-provider/test/app/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {join} from "path";

import {Accounts} from "./services/Accounts.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build
export {rootDir};

@Configuration({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {InteractionsCtrl} from "./app/controllers/oidc/InteractionsCtrl.js";
import {Server} from "./app/Server.js";
import {Accounts} from "./app/services/Accounts.js";

const testDir = __dirname;
const testDir = import.meta.dirname;

const utils = PlatformTestSdk.create({
rootDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/security/passport/test/app/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import methodOverride from "method-override";
import {AuthCtrl} from "./controllers/rest/auth/AuthCtrl.js";
import {Account} from "./models/Account.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build
export {rootDir};

@Configuration({
Expand Down
2 changes: 1 addition & 1 deletion packages/specs/schema/src/utils/generateSpec.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {Post} from "../decorators/operations/route.js";
import {SpecTypes} from "../domain/SpecTypes.js";
import {generateSpec} from "./generateSpec.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

describe("generateSpec()", () => {
describe("OS 3.0.1", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/specs/schema/test/helpers/validateSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {v4} from "uuid";

import {SpecTypes} from "../../src/index.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

export const validateSpec = async (spec: any, version = SpecTypes.SWAGGER) => {
const file = `${rootDir}/spec-${v4()}.json`;
Expand Down
2 changes: 1 addition & 1 deletion packages/specs/swagger/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import getAbsoluteFSPath from "swagger-ui-dist/absolute-path.js";

export const SWAGGER_UI_DIST = getAbsoluteFSPath();
export const ROOT_DIR = __dirname;
export const ROOT_DIR = import.meta.dirname;
2 changes: 1 addition & 1 deletion packages/specs/swagger/test/app/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import compress from "compression";
import cookieParser from "cookie-parser";
import methodOverride from "method-override";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

@Configuration({
rootDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/third-parties/agenda/test/helpers/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import compress from "compression";
import cookieParser from "cookie-parser";
import methodOverride from "method-override";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

@Configuration({
rootDir,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Test1} from "./__mock__/Test1.js";
import {Test2} from "./__mock__/Test2.js";
import {importFiles} from "./importFiles.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

describe("importFiles", () => {
it("should import symbols", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {resolveControllers} from "@tsed/di";

import {importProviders} from "./importProviders.js";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

describe("importProviders", () => {
it("should load providers and merge configuration", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import compress from "compression";
import cookieParser from "cookie-parser";
import methodOverride from "method-override";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

@Configuration({
rootDir,
Expand Down
2 changes: 1 addition & 1 deletion packages/third-parties/formio/test/app/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import methodOverride from "method-override";

import template from "../template/project.json";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build
export {rootDir};

@Configuration({
Expand Down
2 changes: 1 addition & 1 deletion packages/third-parties/pulse/test/helpers/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import compress from "compression";
import cookieParser from "cookie-parser";
import methodOverride from "method-override";

const rootDir = __dirname; // automatically replaced by import.meta.dirname on build
const rootDir = import.meta.dirname; // automatically replaced by import.meta.dirname on build

@Configuration({
rootDir,
Expand Down
Loading

0 comments on commit 4e4f4e2

Please sign in to comment.