Skip to content

Commit 4fd5904

Browse files
committed
rewrite for node 0.10
2 parents b880157 + 4186b42 commit 4fd5904

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/headlessutils.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include "headlessutils.h"
1919
#include <iostream>
20+
#include <string>
2021
#include "nan.h"
2122
#include "uv.h"
2223

@@ -31,7 +32,7 @@ void setZipFunction(Nan::Callback* zF) {
3132
uv_async_t async_zip;
3233

3334
uv_loop_t* loop;
34-
const char* outputDir;
35+
std::string outputDir;
3536

3637
#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
3738
void asyncfunc(uv_async_t* handle) {
@@ -41,9 +42,9 @@ void asyncfunc(uv_async_t* handle, int status) {
4142
Nan::HandleScope scope;
4243
v8::Isolate* isolate = v8::Isolate::GetCurrent();
4344
#if NODE_VERSION_AT_LEAST(0, 11, 0) // > v0.11+
44-
v8::Local<v8::Value> argv[] = { v8::String::NewFromUtf8(isolate, outputDir) };
45+
v8::Local<v8::Value> argv[] = { v8::String::NewFromUtf8(isolate, outputDir.c_str()) };
4546
#else
46-
v8::Local<v8::Value> argv[] = { v8::String::New(outputDir, strlen(outputDir)) };
47+
v8::Local<v8::Value> argv[] = { v8::String::New(outputDir.c_str(), strlen(outputDir.c_str())) };
4748
#endif
4849
headless::zipFunction->Call(1, argv);
4950
}
@@ -63,7 +64,7 @@ void stop() {
6364
}
6465

6566
void zip(const char* dir) {
66-
outputDir = dir;
67+
outputDir = std::string(dir);
6768
uv_async_send(&async_zip);
6869
}
6970

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)