Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ void SpawnAsAdmin(const Nan::FunctionCallbackInfo<Value>& info) {
std::vector<std::string> args;
args.reserve(js_args->Length());
for (uint32_t i = 0; i < js_args->Length(); ++i) {
Local<Value> js_arg = js_args->Get(i);
Local<Context> context = Nan::GetCurrentContext();
Local<Value> js_arg = js_args->Get(context, i).ToLocalChecked();
if (!js_arg->IsString()) {
Nan::ThrowTypeError("Arguments must be an array of strings");
return;
Expand All @@ -81,12 +82,16 @@ void SpawnAsAdmin(const Nan::FunctionCallbackInfo<Value>& info) {
}
}

void Init(v8::Local<v8::Object> exports) {
Nan::SetMethod(exports, "getAuthorizationForm", GetAuthorizationForm);
Nan::SetMethod(exports, "clearAuthorizationCache", ClearAuthorizationCache);
Nan::SetMethod(exports, "spawnAsAdmin", SpawnAsAdmin);
NAN_MODULE_INIT(Init) {
Nan::SetMethod(target, "getAuthorizationForm", GetAuthorizationForm);
Nan::SetMethod(target, "clearAuthorizationCache", ClearAuthorizationCache);
Nan::SetMethod(target, "spawnAsAdmin", SpawnAsAdmin);
}

#if NODE_MAJOR_VERSION >= 10
NAN_MODULE_WORKER_ENABLED(fs_admin, Init)
#else
NODE_MODULE(fs_admin, Init)
#endif

} // namespace spawn_as_admin