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

switch from Node v5.x.x to Node v6.x.x #250

Merged
merged 1 commit into from
Sep 8, 2016
Merged

Conversation

davidchambers
Copy link
Member

This addresses the test failure noted in #248.

As can be seen in the diff, we currently have a guard which prevents doctests from being run in Node v0.10.x (which doesn't support arrow functions). It's completely reasonable to run doctests in just one environment, since their purpose is to keep the documentation up to date rather than guarantee compatibility across Node versions. I suggest the latest stable version if we're to choose just one.

I hope these changes obviate the need to mention a version in CONTRIBUTING.md, as it would be easy for such a note to become out of date. Let's merge this pull request then discuss in #248 whether to add a note.

@@ -60,6 +60,6 @@ setup:
test:
$(ISTANBUL) cover node_modules/.bin/_mocha -- --recursive --timeout 10000
$(ISTANBUL) check-coverage --branches 100
ifneq ($(shell node --version | sed 's/[.][^.]*$$//'),v0.10)
ifeq ($(shell node --version | cut -d . -f 1),v6)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this belongs in the issue, but (assuming makefiles have a concept of else), it might be appropriate to place a message here? That way, a contributor will realise if doctests didn't run and they may need to fix something before opening a PR

Copy link
Member Author

Choose a reason for hiding this comment

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

Very good idea! I'll make a change so that a warning message is emitted in the else branch. :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated. See below. Sample output:

⚠️  Doctests are only run in Node v6.x.x (current version is v4.5.0)

Copy link
Contributor

Choose a reason for hiding this comment

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

Great! I often run in a terminal without escape code support, but the string of escape codes would at least draw my attention :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. It doesn't print properly in the CircleCI logs either. I'll use colour codes instead:

$ echo $'\e[33m\e[7mWARN\e[27m Doctests are only run in Node v6.x.x (current version is '"$(node --version)"$')\e[0m'

Copy link
Contributor

Choose a reason for hiding this comment

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

My primary environment (currently) doesn't actually support any escape codes, but I still think they're a good idea here. (If you were very worried about this, you could have a $TERM=dumb check)

Copy link
Member Author

Choose a reason for hiding this comment

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

After some trial and error, I think I have a version which will do the right thing in most environments:

  1. If $(TERM) is dumb, $(patsubst dumb,,$(TERM)) will evaluate to empty string; otherwise it will evaluate to the value of $(TERM) (which may be empty string).
  2. $(if $(patsubst dumb,,$(TERM)),\033[33m\033[7mWARN\033[27m,[WARN]) will evaluate to [WARN] if the value of $(TERM) is dumb (or empty string); \033[33m\033[7mWARN\033[27m otherwise. 33m sets the foreground colour to yellow, 7m switches foreground and background colours, and 27m undoes the switch.
  3. This appears inside a $'' string, but since $ has special meaning in a makefile we must escape it with an extra dollar sign.

@rjmk, would you mind sanity checking the line below? There's no doubt we're overengineering this, but I believe the only cost is the time I've spent fiddling (which I've quite enjoyed).

One can test this by commenting out lines 61 and 62 then running make test and TERM=dumb make test. CircleCI is happy now too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to me!

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I decided to restrict myself to ASCII regardless of environment. I had too much trouble getting CircleCI to do the right thing. Also, I'm now redirecting the output to stderr.

@rjmk
Copy link
Contributor

rjmk commented Sep 2, 2016

👍

@davidchambers davidchambers force-pushed the dc-node-version branch 22 times, most recently from 000e1d9 to 406c255 Compare September 8, 2016 22:54
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