Skip to content

Commit

Permalink
Fix Node.js 12 compatibility (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janealter authored and sindresorhus committed Sep 26, 2019
1 parent f3ecbe7 commit 659e1a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist: bionic
services:
- xvfb
node_js:
- '12'
- '10'
- '8'
before_install:
Expand Down
8 changes: 4 additions & 4 deletions lib/windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
'use strict';
const path = require('path');
const ffi = require('ffi-napi');
const wchar = require('ref-wchar');
const ref = require('ref');
const struct = require('ref-struct');
const wchar = require('ref-wchar-napi');
const ref = require('ref-napi');
const struct = require('ref-struct-napi');

// Create the struct required to save the window bounds
const Rect = struct({
Expand Down Expand Up @@ -82,7 +82,7 @@ function windows() {
const windowId = ref.address(activeWindowHandle);
// Get the window text length in "characters" to create the buffer
const windowTextLength = user32.GetWindowTextLengthW(activeWindowHandle);
// Allocate a buffer large enough to hold the window text as "Unicode" (UTF-16) characters (using ref-wchar)
// Allocate a buffer large enough to hold the window text as "Unicode" (UTF-16) characters (using ref-wchar-napi)
// This assumes using the "Basic Multilingual Plane" of Unicode, only 2 characters per Unicode code point
// Include some extra bytes for possible null characters
const windowTextBuffer = Buffer.alloc((windowTextLength * 2) + 4);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
},
"optionalDependencies": {
"ffi-napi": "^2.4.5",
"ref": "^1.3.5",
"ref-wchar": "^1.0.2",
"ref-struct": "^1.1.0"
"ref-napi": "^1.4.2",
"ref-wchar-napi": "^1.0.2",
"ref-struct-napi": "^1.1.0"
}
}

0 comments on commit 659e1a5

Please sign in to comment.