Skip to content

Commit

Permalink
fix version cli bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKhanj committed Dec 28, 2023
1 parent 2919559 commit bf0045b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 7 additions & 3 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
import { z } from "zod";
import minimist from "minimist";
import { NestFactory } from "@nestjs/core";
import path, { dirname } from "node:path";
import { DynamicModule, Module } from "@nestjs/common";
import { existsSync, readFileSync } from "node:fs";

import { UserModule } from "./user";
import { ProxyModule } from "./proxy";
import { DatabaseModule } from "./database/database.module";
import { ConfigModule, ConfigService } from "./config";
import { readFileSync } from "node:fs";

@Module({})
export class AppModule {
Expand Down Expand Up @@ -101,8 +102,11 @@ function parseSchema<T extends z.ZodTypeAny>(
}

function showVersion() {
// TODO: fix this
const { version } = JSON.parse(readFileSync("package.json").toString());
let dir = __filename;
while (dir && !existsSync(path.join(dir, "package.json"))) dir = dirname(dir);

const filePath = path.join(dir, "package.json");
const { version } = JSON.parse(readFileSync(filePath).toString());
console.log(`Version: ${version}`);
process.exit(1);
}
Expand Down
10 changes: 2 additions & 8 deletions src/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import {
DynamicModule,
Inject,
Injectable,
Logger,
Module,
} from "@nestjs/common";
import * as net from "net";
import { Transform } from "node:stream";
import { DynamicModule, Injectable, Logger, Module } from "@nestjs/common";

import { UserProxyConfig } from "./config";
import { withErrorLogging } from "./utils";
import { ProxyConfig, UserProxyConfig } from "./config";
import { UserFactory, UserStatsService } from "./user";
import { EventModule, MoxyEventEmitter } from "./event";

Expand Down

0 comments on commit bf0045b

Please sign in to comment.