Skip to content

fix(watch): don't use alternate screen if clearScreen is set - #2125

Merged
lukastaegert merged 3 commits into
rollup:masterfrom
gkatsev:clearscreen
May 25, 2018
Merged

fix(watch): don't use alternate screen if clearScreen is set#2125
lukastaegert merged 3 commits into
rollup:masterfrom
gkatsev:clearscreen

Conversation

@gkatsev

@gkatsev gkatsev commented Apr 13, 2018

Copy link
Copy Markdown
Contributor

Fixes #1804

This is the beginning of a PR to fixes #1804 based on some of the work that people did in that thread with minimal changes. Thanks @evocateur and @JimPanic

I think the changes are good but there's one thing that I'm not sure if there are any side-effects for but would love to get this merged in.

Comment thread bin/src/run/watch.ts Outdated

const initialConfigs = processConfigs(configs);

const clearScreen = initialConfigs.some(config => config.watch.clearScreen);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

just realized this iterator isn't quite right.

Comment thread bin/src/run/watch.ts

let screenWriter = screen.reset;
configs = configs.map(options => {
function processConfigs(configs: RollupWatchOptions[]): RollupWatchOptions[] {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

processConfigs was previously inside of start

Comment thread bin/src/run/watch.ts
code: 'UNKNOWN_OPTION'
});

if (

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what potential side-effects are for this removal.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps rather leave this in if you're unsure, since it seems like it wouldn't necessary apply to the use case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

because processConfigs was pulled out of the start method, it no longer has access to the screenWriter variable, especially since that also happens later on.
I may be able to store it in some other variable and then reset it to stderr in the start method when it gets called.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ah I see, if you can keep the existing behaviour it may be best not to remove something that seems so intentional, especially given this is untested code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Let me update the PR then.

@gkatsev

gkatsev commented Apr 13, 2018

Copy link
Copy Markdown
Contributor Author

Also, I'm not really sure how to add a test for this, any guidance would be appreciated.

@gkatsev

gkatsev commented May 23, 2018

Copy link
Copy Markdown
Contributor Author

Hi, what needs to be done to get this merged?
Thanks.

@lukastaegert

Copy link
Copy Markdown
Member

Hi @gkatsev, sorry for letting you wait that long. I just had another look through your PR and I must admit I have no idea how to add a test myself without adding some kind of mocking framework.

From the code side I think this looks good. Even though it goes against my convictions I would actually be willing to merge this as it is without a test considering it is also a rather small change. Any objections from @guybedford ?

@lukastaegert lukastaegert added this to the 0.60.0 milestone May 24, 2018

@guybedford guybedford left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm also not at all familiar with this part of the codebase, so would also suggest we merge and iterate if there are any problems.

Comment thread bin/src/run/watch.ts
code: 'UNKNOWN_OPTION'
});

if (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps rather leave this in if you're unsure, since it seems like it wouldn't necessary apply to the use case?

@gkatsev

gkatsev commented May 24, 2018

Copy link
Copy Markdown
Contributor Author

@guybedford updated to keep screenWriter set to stderr instead of screen.reset() if clearScreen === false.

@gkatsev

gkatsev commented May 24, 2018

Copy link
Copy Markdown
Contributor Author

@lukastaegert also, no worries, stuff happens and things fall through the cracks.
If this ends up breaking down the line after we merge, feel free to ping me and I'll try and take a look.

@guybedford guybedford left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks @gkatsev for the follow-up here, appreciated.

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

Successfully merging this pull request may close these issues.

rollup --watch clears screen even though it's configured not to

3 participants