2019-10-23 16:26:32 +00:00
|
|
|
// Copyright (c) 2019 GitHub, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|
|
|
|
#define ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|
2019-10-23 16:26:32 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2024-01-04 07:34:08 +00:00
|
|
|
#include "build/build_config.h"
|
2019-10-23 16:26:32 +00:00
|
|
|
#include "v8/include/v8.h"
|
|
|
|
|
|
|
|
namespace node {
|
|
|
|
class Environment;
|
2021-07-02 00:51:37 +00:00
|
|
|
}
|
2019-10-23 16:26:32 +00:00
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
namespace electron::util {
|
2019-10-23 16:26:32 +00:00
|
|
|
|
|
|
|
// Run a script with JS source bundled inside the binary as if it's wrapped
|
|
|
|
// in a function called with a null receiver and arguments specified in C++.
|
|
|
|
// The returned value is empty if an exception is encountered.
|
|
|
|
// JS code run with this method can assume that their top-level
|
|
|
|
// declarations won't affect the global scope.
|
|
|
|
v8::MaybeLocal<v8::Value> CompileAndCall(
|
|
|
|
v8::Local<v8::Context> context,
|
|
|
|
const char* id,
|
|
|
|
std::vector<v8::Local<v8::String>>* parameters,
|
2023-11-30 14:51:35 +00:00
|
|
|
std::vector<v8::Local<v8::Value>>* arguments);
|
2019-10-23 16:26:32 +00:00
|
|
|
|
2024-01-04 07:34:08 +00:00
|
|
|
#if BUILDFLAG(IS_MAC)
|
|
|
|
// Unset all environment variables that start with NODE_. Return false if there
|
|
|
|
// is no node env at all.
|
|
|
|
bool UnsetAllNodeEnvs();
|
|
|
|
#endif
|
|
|
|
|
2022-06-29 19:55:47 +00:00
|
|
|
} // namespace electron::util
|
2019-10-23 16:26:32 +00:00
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_COMMON_NODE_UTIL_H_
|