Skip to content

Commit 880bf2a

Browse files
authored
Merge pull request #347 from sjanuary/headless
Add 0.10 compatability to recent headless code
2 parents 3c6af97 + 6afacbf commit 880bf2a

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

src/appmetrics.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,11 @@ NAN_METHOD(getOption) {
304304
if (info.Length() > 0) {
305305
Local<String> value = info[0]->ToString();
306306
std::string property = loaderApi->getProperty(toStdString(value).c_str());
307+
#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
307308
v8::Local<v8::String> v8str = v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), property.c_str());
309+
#else
310+
v8::Local<v8::String> v8str = v8::String::New(property.c_str(), strlen(property.c_str()));
311+
#endif
308312
info.GetReturnValue().Set<v8::String>(v8str);
309313
} else {
310314
loaderApi->logMessage(warning, "Incorrect number of parameters passed to getOption");

src/headlessutils.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,18 @@ uv_async_t async_zip;
3434
uv_loop_t* loop;
3535
std::string outputDir;
3636

37+
#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
3738
void asyncfunc(uv_async_t* handle) {
39+
#else
40+
void asyncfunc(uv_async_t* handle, int status) {
41+
#endif
3842
Nan::HandleScope scope;
3943
v8::Isolate* isolate = v8::Isolate::GetCurrent();
40-
v8::Local<v8::Value> argv[] = { v8::String::NewFromUtf8(isolate, outputDir.c_str()) };
44+
#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
45+
v8::Local<v8::Value> argv[] = { v8::String::NewFromUtf8(isolate, outputDir.c_str()) };
46+
#else
47+
v8::Local<v8::Value> argv[] = { v8::String::New(outputDir.c_str(), strlen(outputDir.c_str())) };
48+
#endif
4149
headless::zipFunction->Call(1, argv);
4250
}
4351

tests/headless_test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ tap.test('Headless mode should produce a .hcd file', function(t) {
4242
return
4343
}
4444
for (var i = 0, len = files.length; i < len; i++) {
45-
if(files[i].endsWith('.hcd')) {
46-
t.pass(".hcd file found");
45+
if(/(\w+)\.hcd/.test(files[i].toString())) {
46+
t.pass(files[i] + " HCD file found");
4747
t.end();
4848
cleanUp();
4949
return;

0 commit comments

Comments
 (0)