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

Issue#297 resolve cli table dependency #311

Closed
wants to merge 7 commits into from
Closed

Issue#297 resolve cli table dependency #311

wants to merge 7 commits into from

Conversation

matthewberryman
Copy link

Supersedes #302 - fixes test issues caused by colors by setting the style parameter as @Turbo87 suggested in #302 (comment)

@matthewberryman
Copy link
Author

This is working in node v10 but still failing in node v8 per https://travis-ci.org/zemirco/json2csv/jobs/397145497 (expected doesn't have colors but actual does), I will chase that one down.

@matthewberryman
Copy link
Author

I've tested locally for 8. I was assuming the test suite should be the same for v8 and v10 (hence I didn't test with v8 previously my bad); the problem with my assumption is that I noticed the node version detection wasn't correct in the fork I forked from (https://github.com/schalkneethling/json2csv/blob/91cbe4fb023d35749221775eed65184909dc519d/test/CLI.js#L720 checks only first digit so returns 1 for node v10.x.x) but is fixed in zemirco/json2csv master branch.

* specify this in package.json too
* also can remove check for node < 8 on some tests as they work on v6 
and v7
@matthewberryman
Copy link
Author

Per discussion on #302 I've removed v4 and v5 from the .travis.yml list and also specified the requirement for node >=6.0.0 in the package.json file. With that chaange, and since the other work done on style fixes the other broken tests for node v6 and v7, I've now removed the check for node < v8 in CLI.js so that all tests are run (and now pass after installing and testing against different node versions locally and also in travis https://travis-ci.org/zemirco/json2csv/builds/397153027?utm_source=github_status&utm_medium=notification ).

@knownasilya
Copy link
Collaborator

@matthewberryman I'd love to keep colors normally, but disable them for tests. Think you could give that a try as well?

@matthewberryman
Copy link
Author

@knownasilya Yes that's a good point. I'll give it a go.

@matthewberryman
Copy link
Author

@knownasilya 810ca51 adds a new command line option for pretty formatting without colour, that behaves as expected (running at CLI on some json I have, plus tests), with --pretty still adding color

@juanjoDiaz
Copy link
Collaborator

I don't think that we should have two pretty print options.

In fact, I don't think that we should have a pretty print option at all. We should have a separate library to do json2csv .... | pretty-print, imho. So the user can even select his config for the table.

For now, I'd rather make the cli-table an optional dependency and let the user bring either cli-table, cli-table2 or cli-table3 as he wants. I think that it was a mistake to eve bring cli-table2 and it would be same to now update to cli-table-3.

Btw, there are many changes unrelated to the PR (spaces mainly). Those are good changes but would be better as a separate PR.

@@ -35,6 +35,7 @@ program
.option('-a, --include-empty-rows', 'Includes empty rows in the resulting CSV output.')
.option('-b, --with-bom', 'Includes BOM character at the beginning of the csv.')
.option('-p, --pretty', 'Use only when printing to console. Logs output in pretty tables.')
.option('-P, --pretty-without-color', 'Use only when printing to console. Logs output in pretty tables, but without color.')
Copy link

Choose a reason for hiding this comment

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

this is unnecessary. cli-table3 through colors already supports a --no-color by default, so a dedicated option should not be needed here.

Copy link
Author

Choose a reason for hiding this comment

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

The tests in CLI.js call child_process.exec on json2csv.js, so short of adding another command line option here to json2csv (to keep colour by default per #311 (comment) ) , or a fundamental re-write of the tests, this does seem necessary to pass that option through to json2csv as a process argument, because of the way it's called.

@matthewberryman
Copy link
Author

@juanjoDiaz
There are some new line character differences etc. auto changed by my editor that explains most of the whitespace changes. I can change that if necessary.

I think removing the pretty print code in next major version bump makes sense, as its adding a lot of complexity and dependencies for a feature that I am guessing isn't used much, but in the mean time having cli-table3 in place solves several issues (this PR solves both #278 and #297 ).

@knownasilya
Copy link
Collaborator

knownasilya commented Jul 12, 2018

Closed in favor of #312

Thanks for the contribution and getting this moving.

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.

4 participants