Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "v8 version" subcommand to llnode #431

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"src/node-constants.cc",
"src/settings.cc",
],
"cflags": [ '-DLLNODE_VERSION=<!(grep -Po \'"version": \K(".*")\' <(module_root_dir)/package.json)' ],
Copy link

@zhxinyu zhxinyu Sep 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the new feature support in Mac OS system? As far as I know, option P is not supported in grep in Mac OS, neither as \K

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a compile-time step, so technically the feature would support any OS once we have a built artifact, but you're right that this wouldn't build on MacOS. We can change this line to:
"cflags": [ '-DLLNODE_VERSION=<!(grep \\"version\\" <(module_root_dir)/package.json | sed \'s/.*\\("[0-9\\.]*"\\).*/\\1/g\')' ],
if that works on Mac? Although I guess that also brings up the issue of Windows...

Copy link

@zhxinyu zhxinyu Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I confirm that it should work on Mac. and I think the double \ in \\"version\\" can be replaced by single \.

In particular, I tried grep "version" < package.json | sed 's/.*\("[0-9\.]*"\).*/\1/g' and echo "$(grep \"version\" < package.json | sed 's/.*\("[0-9\.]*"\).*/\1/g')"in cli.

"conditions": [
[ "OS == 'win'", {
"sources": [
Expand Down
10 changes: 10 additions & 0 deletions src/llnode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,12 @@ std::string GetActiveRequestsCmd::GetResultMessage(node::Environment* env,
return result_message.str();
}

bool GetLLNodeVersionCmd::DoExecute(SBDebugger d, char** cmd,
SBCommandReturnObject& result) {
result.Printf("llnode version %s", LLNODE_VERSION);
return true;
}


void InitDebugMode() {
bool is_debug_mode = false;
Expand Down Expand Up @@ -522,6 +528,10 @@ bool PluginInitialize(SBDebugger d) {
"Print all pending requests in the queue. Equivalent to "
"running process._getActiveRequests() on the living process.\n");

v8.AddCommand(
"version", new llnode::GetLLNodeVersionCmd(),
"print llnode version");

// Set initial value for color support
llnode::Settings* settings = llnode::Settings::GetSettings();
settings->SetColor("auto");
Expand Down
6 changes: 6 additions & 0 deletions src/llnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ class GetActiveRequestsCmd : public WorkqueueCmd {
std::string GetResultMessage(node::Environment* env, Error& err) override;
};

class GetLLNodeVersionCmd : public CommandBase {
public:
bool DoExecute(lldb::SBDebugger d, char** cmd,
lldb::SBCommandReturnObject& result) override;
};


} // namespace llnode

Expand Down