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

--clear-screen --watch slowely scrolls down after each rebuild #465

Closed
vlatkoB opened this issue Oct 23, 2019 · 5 comments
Closed

--clear-screen --watch slowely scrolls down after each rebuild #465

vlatkoB opened this issue Oct 23, 2019 · 5 comments

Comments

@vlatkoB
Copy link

vlatkoB commented Oct 23, 2019

  • spago v0.10.0.0
  • linux, bash

When using this cmd (with build or bundle-app, and both directly or via yarn)

spago bundle-app --clear-screen --main Main --to dist/app.js --watch

The screen on the first run:

yarn run v1.19.1
$ spago bundle-app --clear-screen --main Main --to dist/app.js --watch
Installation complete.
           Src   Lib   All
Warnings   0     0     0  
Errors     0     0     0  
Build succeeded.
Bundle succeeded and output file to dist/app.js
Success! Waiting for next file change.
Type help for available commands. Press enter to force a rebuild.

The screen on the second run:

(empty line)
(empty line)
(empty line)
(empty line)
(empty line)
(empty line)
(empty line)
(empty line)
(empty line)
(empty line)
File changed, triggered a build: ".../Router.purs"
Compiling Main
           Src   Lib   All
Warnings   0     0     0  
Errors     0     0     0  
Build succeeded.
Bundle succeeded and output file to dist/app.js
Success! Waiting for the next file change.
Type help for available commands. Press enter to force a rebuild.

Next builds simply show below the previous one and so on.

@jhrcek
Copy link
Collaborator

jhrcek commented Oct 23, 2019

I briefly looked into this and it seem it should be easy to fix. Just change this line

https://github.com/spacchetti/spago/blob/0bdf296d14efaba9fb6798768c5281446dafe9a2/src/Spago/Watch.hs#L68

like this:

-          when (shouldClear == DoClear) $ liftIO clearScreen
+          when (shouldClear == DoClear) $ liftIO $ do
+            clearScreen
+            setCursorPosition 0 0

Tried this locally and it seems to work fine, but it only clears the screen on rebuild (after you change the file), not on the initial build. Would the expected behavior be to also clear the screen on the initial run of the command?

@vlatkoB
Copy link
Author

vlatkoB commented Oct 23, 2019

Thanks for looking into it. It works as expected. :-)

I do not think the first build should trigger clearing the screen, so it seems to me it is working correctly.

Will you make a PR?

@jhrcek
Copy link
Collaborator

jhrcek commented Oct 23, 2019

Sure, I will

@vlatkoB
Copy link
Author

vlatkoB commented Oct 26, 2019

A question related to --watch. What about adding the --ignore-pattern (command line and/or config), so --watch does not jump on every file change?
With emacs, when you edit any file, it creates a lockfile named .#edited_filename in the same directory and --watch kicks in.

@f-f
Copy link
Member

f-f commented Nov 4, 2019

@vlatkoB I think we should just ignore the emacs pattern in general, as you'd always want to exclude these kinds of events.

I'll close this since it has been fixed in #466 and I opened #477 to track your usecase

@f-f f-f closed this as completed Nov 4, 2019
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

3 participants