Skip to content

Commit

Permalink
refactor: remove __dirname from production code (#7345)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Oct 30, 2024
1 parent 6aa2d59 commit a20df05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/config/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { PACKAGE_VERSION } from "./_version";
import type { DeviceConfigIndexEntry } from "./devices/DeviceConfig";

/** The absolute path of the embedded configuration directory */
export const configDir = path.resolve(__dirname, "../config");
export const configDir = path.resolve(
path.dirname(require.resolve("@zwave-js/config/package.json")),
"config",
);
/** The (optional) absolute path of an external configuration directory */
export function externalConfigDir(): string | undefined {
return process.env.ZWAVEJS_EXTERNAL_CONFIG;
Expand Down
7 changes: 1 addition & 6 deletions packages/core/src/log/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ export class ZWaveLogContainer extends winston.Container {
maxFiles: 7,
nodeFilter: stringToNodeList(process.env.LOG_NODES),
transports: undefined as any,
filename: require.main
? path.join(
path.dirname(require.main.filename),
`zwavejs_%DATE%.log`,
)
: path.join(__dirname, "../../..", `zwavejs_%DATE%.log`),
filename: path.join(process.cwd(), `zwavejs_%DATE%.log`),
forceConsole: false,
};

Expand Down
4 changes: 2 additions & 2 deletions packages/flash/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const driver = new Driver(port, {
loadConfiguration: false,
},
storage: {
cacheDir: path.join(__dirname, "cache"),
lockDir: path.join(__dirname, "cache/locks"),
cacheDir: path.join(process.cwd(), "cache"),
lockDir: path.join(process.cwd(), "cache/locks"),
},
allowBootloaderOnly: true,
})
Expand Down

0 comments on commit a20df05

Please sign in to comment.