From 9ecef2e114145fcb95c7d7433a58e759b0cc767f Mon Sep 17 00:00:00 2001 From: TaoZeyu Date: Wed, 25 Oct 2023 02:44:35 -0500 Subject: [PATCH] fix(api): cannot return useable monitor (#2) --- src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index dbe8516..60942e1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,4 @@ +import { join } from "path"; import { platform } from "os"; let current: MacPowerMonitor | null = null; @@ -13,7 +14,7 @@ export interface MacPowerMonitor { } export function createMacPowerMonitor(): MacPowerMonitor { - if (platform() === "darwin") { + if (platform() !== "darwin") { return createDoNothing(); } if (current) { @@ -21,7 +22,7 @@ export function createMacPowerMonitor(): MacPowerMonitor { } let didStop = false; - const node = require(`./mac-power-monitor.darwin-${process.platform}.node`); + const node = require(join(__dirname, `./mac-power-monitor.darwin-${process.arch}.node`)); const monitor: Omit = { unregisterAll: () => { assertIsRunning();