Skip to content

Commit

Permalink
Fix node 12
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed May 31, 2019
1 parent 818ddb2 commit 16c0004
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

var resolve = require('path').resolve
var isWindows = process.platform === 'win32'
var info = isWindows ? require('bindings')('VersionInfo') : null
var info = isWindows ? require('bindings')('VersionInfo').getInfo : null

module.exports = function (file) {
if (typeof file !== 'string') {
Expand Down
7 changes: 3 additions & 4 deletions src/VersionInfo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using namespace std;
using namespace utf8util;

void CreateObject(const Nan::FunctionCallbackInfo<v8::Value>& info) {
NAN_METHOD(getInfo) {
if (!info[0]->IsString()) {
return Nan::ThrowError("win-version-info requires a string filename");
}
Expand Down Expand Up @@ -36,9 +36,8 @@ void CreateObject(const Nan::FunctionCallbackInfo<v8::Value>& info) {
info.GetReturnValue().Set(metadata);
}

void Init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
module->Set(Nan::New("exports").ToLocalChecked(),
Nan::New<v8::FunctionTemplate>(CreateObject)->GetFunction());
NAN_MODULE_INIT(Init) {
NAN_EXPORT(target, getInfo);
}

NODE_MODULE(VersionInfo, Init)
8 changes: 3 additions & 5 deletions src/showver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ void ReadFixedFileInfo(VS_FIXEDFILEINFO* pValue, v8::Local<v8::Object> &metadata
std::string version = v.str();

if (version != "0.0.0.0") {
metadata->Set(
Nan::Set(
metadata,
Nan::New("FileVersion").ToLocalChecked(),
Nan::New(version).ToLocalChecked()
);
Expand All @@ -150,10 +151,7 @@ void SetUTF16Pair(wchar_t *key, wchar_t *value, v8::Local<v8::Object> &metadata)
if (isVersionKey(utf8Key) && isEmptyVersion(utf8Val)) return;

v8::Local<v8::String> k = Nan::New(utf8Key).ToLocalChecked();

if (!metadata->Has(k)) {
metadata->Set(k, Nan::New(utf8Val).ToLocalChecked());
}
Nan::Set(metadata, k, Nan::New(utf8Val).ToLocalChecked());
}

void ReadFileInfo(void* pVer, DWORD size, v8::Local<v8::Object> &metadata) {
Expand Down
2 changes: 1 addition & 1 deletion test/basic-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ if (process.platform !== 'win32') {
})

test('binding throws on non-string', function (t) {
var info = require('bindings')('VersionInfo')
var info = require('bindings')('VersionInfo').getInfo

t.plan(1)

Expand Down

0 comments on commit 16c0004

Please sign in to comment.