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

Not passing --browser to reload binary parsing is interpreted as it was there #384

Open
jest opened this issue Oct 21, 2024 · 0 comments
Open

Comments

@jest
Copy link

jest commented Oct 21, 2024

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

The problem is that when calling the reload binary withour passing --browser, the browser is launched anyway.

The cause is the wrong parsing of options.browser field. When --browser is not passed, the field value is undefined. However, before passing this to reload() function, the value is casted to string, resulting in "undefined", and then double-negated (with !!) turning it into true.

The solution is to double-negate options.browser before converting it into a string.

Here is the diff that solved my problem:

diff --git a/node_modules/reload/bin/reload b/node_modules/reload/bin/reload
index 4e005dc..afcf620 100755
--- a/node_modules/reload/bin/reload
+++ b/node_modules/reload/bin/reload
@@ -40,7 +40,7 @@ nodemon({
   watch: path.join(options.watchDir, '/**/*'), // Watch all subdirectories
   ignore: options.ignore.split(','),
   script: `${serverFile}`,
-  args: [`${options.port}`, `${options.dir}`, !!`${options.browser}`, `${options.hostname}`, `${runFile}`, `${options.startPage}`, `${options.fallback}`, `${options.verbose}`]
+  args: [`${options.port}`, `${options.dir}`, `${!!options.browser}`, `${options.hostname}`, `${runFile}`, `${options.startPage}`, `${options.fallback}`, `${options.verbose}`]
 })
 
 nodemon.on('start', function () {

This issue body was partially generated by patch-package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant