File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -6,27 +6,29 @@ import preGyp from '@mapbox/node-pre-gyp';
6
6
7
7
const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) ) ;
8
8
9
- const require = createRequire ( import . meta. url ) ;
9
+ const getAddon = ( ) => {
10
+ const require = createRequire ( import . meta. url ) ;
10
11
11
- const bindingPath = preGyp . find ( path . resolve ( path . join ( __dirname , '../package.json' ) ) ) ;
12
+ const bindingPath = preGyp . find ( path . resolve ( path . join ( __dirname , '../package.json' ) ) ) ;
12
13
13
- const addon = ( fs . existsSync ( bindingPath ) ) ? require ( bindingPath ) : {
14
- getActiveWindow ( ) { } ,
15
- getOpenWindows ( ) { } ,
14
+ return ( fs . existsSync ( bindingPath ) ) ? require ( bindingPath ) : {
15
+ getActiveWindow ( ) { } ,
16
+ getOpenWindows ( ) { } ,
17
+ } ;
16
18
} ;
17
19
18
20
export async function activeWindow ( ) {
19
- return addon . getActiveWindow ( ) ;
21
+ return getAddon ( ) . getActiveWindow ( ) ;
20
22
}
21
23
22
24
export function activeWindowSync ( ) {
23
- return addon . getActiveWindow ( ) ;
25
+ return getAddon ( ) . getActiveWindow ( ) ;
24
26
}
25
27
26
28
export function openWindows ( ) {
27
- return addon . getOpenWindows ( ) ;
29
+ return getAddon ( ) . getOpenWindows ( ) ;
28
30
}
29
31
30
32
export function openWindowsSync ( ) {
31
- return addon . getOpenWindows ( ) ;
33
+ return getAddon ( ) . getOpenWindows ( ) ;
32
34
}
You can’t perform that action at this time.
0 commit comments