diff --git a/package.json b/package.json index b10a44a..76035cf 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "author": "Jacob Groundwater ", "license": "MIT", "dependencies": { - "nan": "^1.2.0", - "minimist": "^0.0.10" + "minimist": "^0.0.10", + "nan": "^2.0.9" }, "bin": { "century": "century.js" diff --git a/src/binding.cc b/src/binding.cc index fbbb4a0..3fb0bff 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -1,10 +1,10 @@ #include "binding.h" void InitAll(Handle exports) { - exports->Set(NanNew("wait"), - NanNew(Wait)->GetFunction()); - exports->Set(NanNew("demo"), - NanNew(Demo)->GetFunction()); + exports->Set(Nan::New("wait").ToLocalChecked(), + Nan::New(Wait)->GetFunction()); + exports->Set(Nan::New("demo").ToLocalChecked(), + Nan::New(Demo)->GetFunction()); } NODE_MODULE(binding, InitAll) diff --git a/src/popen.cc b/src/popen.cc index e5d346a..39b4aa8 100644 --- a/src/popen.cc +++ b/src/popen.cc @@ -4,9 +4,9 @@ // this is just for demo purposes NAN_METHOD(Demo) { - NanScope(); + Nan::HandleScope scope; popen("sleep 30", "r"); - NanReturnUndefined(); + return; } diff --git a/src/wait.cc b/src/wait.cc index 08fcb5d..e5cd4c5 100644 --- a/src/wait.cc +++ b/src/wait.cc @@ -1,43 +1,33 @@ #include "binding.h" NAN_METHOD(Wait) { - NanScope(); - + Nan::HandleScope scope; int status; // non-blocking - // do not wait for a dead child because this is run on the main event loop // this method is intended for init, who inherits children that it did not spawn pid_t ok = waitpid(-1, &status, WNOHANG); if (ok == 0) { - // no child exited - NanReturnNull(); - } - else if (ok == -1) { - - // no children - NanReturnUndefined(); - } - else { + info.GetReturnValue().Set(Nan::Null()); + } else if (ok != -1) { // we caught a child exiting - // the exit status is an integer containing bits of useful information - Handle o = NanNew(); + v8::Local o = Nan::New(); - o->Set(NanNew("_") , NanNew(status)); - o->Set(NanNew("exited") , NanNew(WIFEXITED(status))); - o->Set(NanNew("status") , NanNew(WEXITSTATUS(status))); - o->Set(NanNew("signal") , NanNew(WIFSIGNALED(status))); - o->Set(NanNew("termsig") , NanNew(WTERMSIG(status))); - o->Set(NanNew("coredump") , NanNew(WCOREDUMP(status))); - o->Set(NanNew("ifstopped"), NanNew(WIFSTOPPED(status))); - o->Set(NanNew("stopsig") , NanNew(WSTOPSIG(status))); - o->Set(NanNew("continued"), NanNew(WIFCONTINUED(status))); + o->Set(Nan::New("_").ToLocalChecked() , Nan::New(status)); + o->Set(Nan::New("exited").ToLocalChecked() , Nan::New(WIFEXITED(status))); + o->Set(Nan::New("status").ToLocalChecked() , Nan::New(WEXITSTATUS(status))); + o->Set(Nan::New("signal").ToLocalChecked() , Nan::New(WIFSIGNALED(status))); + o->Set(Nan::New("termsig").ToLocalChecked() , Nan::New(WTERMSIG(status))); + o->Set(Nan::New("coredump").ToLocalChecked() , Nan::New(WCOREDUMP(status))); + o->Set(Nan::New("ifstopped").ToLocalChecked(), Nan::New(WIFSTOPPED(status))); + o->Set(Nan::New("stopsig").ToLocalChecked() , Nan::New(WSTOPSIG(status))); + o->Set(Nan::New("continued").ToLocalChecked(), Nan::New(WIFCONTINUED(status))); - NanReturnValue(o); + info.GetReturnValue().Set(o); } }