fix admn controller
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import type { Response } from 'express';
|
||||
import { createRequire } from 'node:module';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
@@ -41,14 +40,11 @@ const userUpdateSchema = z.object({
|
||||
|
||||
type PackageJson = { version?: string };
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const readPackageJsonSafe = (filePath: string | null): PackageJson | null => {
|
||||
if (!filePath || !fs.existsSync(filePath)) {
|
||||
return null;
|
||||
}
|
||||
if (!filePath || !fs.existsSync(filePath)) return null;
|
||||
|
||||
try {
|
||||
return JSON.parse(fs.readFileSync(filePath, 'utf8')) as PackageJson;
|
||||
@@ -62,15 +58,10 @@ const findNearestPackageJson = (startDir: string): string | null => {
|
||||
|
||||
while (true) {
|
||||
const candidate = path.join(currentDir, 'package.json');
|
||||
if (fs.existsSync(candidate)) {
|
||||
return candidate;
|
||||
}
|
||||
if (fs.existsSync(candidate)) return candidate;
|
||||
|
||||
const parentDir = path.dirname(currentDir);
|
||||
if (parentDir === currentDir) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (parentDir == currentDir) return null;
|
||||
currentDir = parentDir;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user