sezna / nps

NPM Package Scripts -- All the benefits of npm scripts without the cost of a bloated package.json and limits of json
MIT License
1.43k stars 93 forks source link

Better commands in series console output #137

Open tleunen opened 7 years ago

tleunen commented 7 years ago

I'm not sure if it's possible with the current state of nps and nps-utils, or if this is something you all would be interested in.

When I use multiple commands in series, I usually have 3 or more commands, which makes the output really not clear with the command on multiple lines.

So, instead of having this following thing:

nps executing: rimraf dist/prod && node scripts/something.js -o src/generated-file.js && webpack --config ./webpack --env.custom_value something-awesome

Because everything is in series, would it make sense to split the output in X "nps executing" lines?

nps executing: rimraf dist/prod
nps executing: node scripts/something.js -o src/generated-file.js
nps executing: webpack --config ./webpack --env.custom_value something-awesome

Or in one line, with a bit of formatting?

nps executing: rimraf dist/prod && 
    node scripts/something.js -o src/generated-file.js && 
    webpack --config ./webpack --env.custom_value something-awesome

Ideally, this should work for && in general, not only with npsUtils

kentcdodds commented 7 years ago

If we can come up with a good way to do that I'd be happy to do that. Unfortunately I don't see it being very reasonable to do reliably without parsing the command which I don't really want to do.

Now we could improve npsUtils to add a newline with series or you could write your own series function to do that.

Anyway, definitely happy to entertain a PR for that if it's reasonable.

tleunen commented 7 years ago

Probably better to write my own function to add the newline. Quite simple fn.

In addition to that, maybe we could have some prettyPrint functions to keep the log under 80 characters or any number of characters available in the terminal).

I wonder if something exists already for that.

kentcdodds commented 7 years ago

Not sure I follow what you mean, but I know that yargs does change it's --help output based on the width of your terminal... Maybe they use something?