mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
Fixes: https://github.com/nodejs/node/issues/50993 Refs: https://github.com/nodejs/node/issues/51451 test: remove unnecessary comment src: conform to style guidelines src: change flag to `--env-file-optional` test: revert automatic linter changes doc: fix typos src: change flag to `--env-file-if-exists` src: refactor `env_file_data` and `GetEnvFileDataFromArgs` test: clean up tests src: print error when file not found test: remove unnecessary extras PR-URL: https://github.com/nodejs/node/pull/53060 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#ifndef SRC_NODE_DOTENV_H_
|
|
#define SRC_NODE_DOTENV_H_
|
|
|
|
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
|
|
#include "util-inl.h"
|
|
#include "v8.h"
|
|
|
|
#include <map>
|
|
|
|
namespace node {
|
|
|
|
class Dotenv {
|
|
public:
|
|
enum ParseResult { Valid, FileError, InvalidContent };
|
|
struct env_file_data {
|
|
std::string path;
|
|
bool is_optional;
|
|
};
|
|
|
|
Dotenv() = default;
|
|
Dotenv(const Dotenv& d) = delete;
|
|
Dotenv(Dotenv&& d) noexcept = default;
|
|
Dotenv& operator=(Dotenv&& d) noexcept = default;
|
|
Dotenv& operator=(const Dotenv& d) = delete;
|
|
~Dotenv() = default;
|
|
|
|
void ParseContent(const std::string_view content);
|
|
ParseResult ParsePath(const std::string_view path);
|
|
void AssignNodeOptionsIfAvailable(std::string* node_options) const;
|
|
void SetEnvironment(Environment* env);
|
|
v8::Local<v8::Object> ToObject(Environment* env) const;
|
|
|
|
static std::vector<env_file_data> GetDataFromArgs(
|
|
const std::vector<std::string>& args);
|
|
|
|
private:
|
|
std::map<std::string, std::string> store_;
|
|
};
|
|
|
|
} // namespace node
|
|
|
|
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
|
|
|
|
#endif // SRC_NODE_DOTENV_H_
|