Skip to content

Commit

Permalink
refactor: get dirname by using module.filename
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Nov 25, 2023
1 parent a712bc8 commit 3774168
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 9 deletions.
3 changes: 1 addition & 2 deletions src/classes/worker.ts
Expand Up @@ -18,7 +18,6 @@ import { MinimalQueue } from '../types';
import {
delay,
DELAY_TIME_1,
getDirName,
isNotConnectionError,
isRedisInstance,
WORKER_SUFFIX,
Expand Down Expand Up @@ -245,7 +244,7 @@ export class Worker<
? 'main-worker.js'
: 'main.js';
let mainFilePath = path.join(
getDirName(import.meta.url),
path.dirname(module.filename),
`${mainFile}`,
);
try {
Expand Down
7 changes: 0 additions & 7 deletions src/utils.ts
Expand Up @@ -8,17 +8,10 @@ import { AbortController } from 'node-abort-controller';
import { CONNECTION_CLOSED_ERROR_MSG } from 'ioredis/built/utils';
import { ChildMessage, RedisClient } from './interfaces';
import { EventEmitter } from 'events';
import * as path from 'path';
import * as semver from 'semver';
import { fileURLToPath } from 'url';

export const errorObject: { [index: string]: any } = { value: null };

export const getDirName = function (moduleUrl: string) {
const filename = fileURLToPath(moduleUrl);
return path.dirname(filename);
};

export function tryCatch(
fn: (...args: any) => any,
ctx: any,
Expand Down

0 comments on commit 3774168

Please sign in to comment.