Skip to content

Commit

Permalink
fix(api): cannot return useable monitor (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Moskize91 authored Oct 25, 2023
1 parent 93a6388 commit 9ecef2e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { join } from "path";
import { platform } from "os";

let current: MacPowerMonitor | null = null;
Expand All @@ -13,15 +14,15 @@ export interface MacPowerMonitor {
}

export function createMacPowerMonitor(): MacPowerMonitor {
if (platform() === "darwin") {
if (platform() !== "darwin") {
return createDoNothing();
}
if (current) {
throw new Error("did create. should dispose the previous");
}
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<MacPowerMonitor, "canSleep"> = {
unregisterAll: () => {
assertIsRunning();
Expand Down

0 comments on commit 9ecef2e

Please sign in to comment.