-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Conversation
/** | ||
* 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)) | ||
) | ||
} |
There was a problem hiding this comment.
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 🤗
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? 🤔 |
No problem! :) Yeah, that makes sense! I will close this PR and update the discussions thread with current idea of implementation 😉 |
Link to the discussion: #2278
To be done: