Skip to content

Commit

Permalink
Fix --help option
Browse files Browse the repository at this point in the history
Nexe's patches bypass Node's print_help check, meaning that `--help` is ignored
when running `./MarkerEditor --help`, and the editor spins up.

To get past this, inject a print_help check inside of the patch that Nexe adds,
so our print_help patch shows as expected.
  • Loading branch information
danrahn committed Apr 27, 2024
1 parent 5c8dd95 commit 9ff8281
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Build/build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,24 @@ async function toExe() {
`"\\n\\nUse '--' to pass arguments directly to Marker Editor (e.g. ${bin} -- -v)\\n"`
);

// nexe short-circuits StartExecution, skipping the print_help check, but we want that.
await compiler.replaceInFileAsync(
'src/node.cc',
'return StartExecution(env, "internal/main/run_main_module"); }',
` if (per_process::cli_options->print_help) {
return StartExecution(env, "internal/main/print_help");
}
return StartExecution(env, "internal/main/run_main_module");
}`
);

await compiler.replaceInFileAsync(
'lib/internal/main/print_help.js',
/^ {4}'Usage: node/,
` 'NOTE: Printing Node help use \\'--\\' to pass arguments directly to Marker Editor\\n` +
` e.g. ${bin} -- --help\\n\\n' +\n 'Usage: node`
` 'Usage: node`,
` 'NOTE: Printing Node help. Use \\'--\\' to pass arguments directly to Marker Editor\\n' +\n` +
` ' e.g. ${bin} -- --help\\n\\n' +\n` +
` 'Usage: node`
);

return next();
Expand Down
1 change: 1 addition & 0 deletions Server/MarkerEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ function handlePost(req, res) {
* Parse command line arguments.
* @returns {CLIArguments} */
function checkArgs() {
Log.info(`MarkerEditor - Command Line Arguments: ${process.argv.join(', ')}`);
const argInfo = {
isTest : false,
configOverride : null,
Expand Down

0 comments on commit 9ff8281

Please sign in to comment.