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

Added a watch mode to the build command in the CLI #2290

Closed

Conversation

DCzajkowski
Copy link

@DCzajkowski DCzajkowski commented Sep 2, 2020

Link to the discussion: #2278

To be done:

  • tests 😅

Comment on lines +88 to +114
/**
* Logs to the console with the last item pulled to the right edge of the terminal window.
*
* @param {...(string | [string, string])} [items] - When an item is a tuple of two strings, the first value is a
* modifier (e.g. color) that does not take any vertical space on the screen (i.e. its characters are not occupying
* available columns). The second value is a string that is visible to the user and does take vertical space.
*/
export function pad(...items) {
const paddingWidth =
process.stdout.columns -
// all strings
sum(items.map(item => (isArray(item) ? item[1] : item).length)) -
// all spaces between strings
(items.length - 1) -
// additional space character from the padding section
1

const padding = Array(paddingWidth || 0)
.fill(' ')
.join('')

log(
...initial(items).map(item => (isArray(item) ? item[0](item[1]) : item)),
padding,
(item => (isArray(item) ? item[0](item[1]) : item))(last(items))
)
}
Copy link
Author

Choose a reason for hiding this comment

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

This function looks a little fragile to me, but I don't know how to make it better. Is there a package to easily offset things to the right edge? Looking forward to your feedback 🤗

@adamwathan
Copy link
Member

Meant to reply to the discussion but forgot! So my go to for this is just postcss-cli which has a watch mode and works great. I am not opposed to exposing this stuff through our own CLI tool but wonder if maybe we should just build some wrapper on top of that? 🤔

@DCzajkowski
Copy link
Author

No problem! :)

Yeah, that makes sense! I will close this PR and update the discussions thread with current idea of implementation 😉

@DCzajkowski DCzajkowski closed this Sep 3, 2020
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.

2 participants