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

Fixed Mocha for CoffeeScript 1.7+ and Travis CI errors #6

Closed
wants to merge 7 commits into from

Conversation

MrSaints
Copy link

Gruntfile.js and test are not currently compatible with CoffeeScript 1.7+ and they return the following error when executed:

Error: Use CoffeeScript.register() or require the coffee-script/register module to require .coffee.md files.

According to CoffeeScript's change log:

When requiring CoffeeScript files in Node you must now explicitly register the compiler. This can be done with require 'coffee-script/register' or CoffeeScript.register(). Also for configuration such as Mocha's, use coffee-script/register.

These changes fixes the error for when CoffeeScript 1.7+ is installed globally.

Also, https://github.com/hubot-scripts/hubot-example (which uses ~1.6) should probably be removed or edited to reflect the recent changes (Yeoman generator).

@hyeomans
Copy link

hyeomans commented Dec 5, 2014

A temporary solution for this is to include the following line on your mocha.opts file:

#test/mocha.opts
--compilers mocha --compilers coffee:coffee-script/register

@technicalpickles
Copy link
Member

Thanks for digging into this. Working through hubotio/hubot#863 and running basically into the same problems.

@@ -9,7 +9,7 @@ module.exports = function(grunt) {
test: {
options: {
reporter: 'spec',
require: 'coffee-script'
require: 'coffee-script/register'
Copy link
Member

Choose a reason for hiding this comment

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

package.json still has [email protected] for development. So, probably need to bump that, or revert this change.

Copy link
Author

Choose a reason for hiding this comment

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

If we do revert this, we may be locking all future Hubot scripts to < CoffeeScript 1.7. I'm not sure what's the best way to go about this (perhaps some condition for Travis?), but I personally feel that we should just bump it as it should only affect newly generated scripts.

Sorry, my bad. It's the generator's CoffeeScript version that you're referring to. Yea, we can revert this.

@technicalpickles
Copy link
Member

I'm trying to think through this, and I'm having a hard time if scripts generated this will work with hubot as it is now, or if there needs to be support for newer coffeescript (ie hubotio/hubot#863)

@technicalpickles
Copy link
Member

I tried generating a new script, then running grunt test, and got:

$ grunt test
Running "mochaTest:test" (mochaTest) task
Warning: Cannot find module 'coffee-script/register' Use --force to continue.

Aborted due to warnings.

Looks like coffee-script needs to be a dependency (or dev dependency) of the generated script.

@MrSaints
Copy link
Author

I agree. You might have to add the latest CoffeeScript as a dependency (or at least a dev dependency) in the script template. I realised that it doesn't work too well even with CoffeeScript installed globally if it is done via a NVM environment. It works best with a local copy of CoffeeScript in its directory.

@MrSaints MrSaints changed the title Fixed Mocha for CoffeeScript 1.7+ Fixed Mocha for CoffeeScript 1.7+ and Travis CI errors Feb 21, 2015
cylwin added a commit to cylwin/cozy-template-coffee that referenced this pull request Feb 23, 2015
When I ran test with the old file I had this error : 

Running mocha caught exception: 
Error: Command failed: 
/home/baremec/.node/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:210
          throw new Error("Use CoffeeScript.register() or require the coffee-s
                ^
Error: Use CoffeeScript.register() or require the coffee-script/register module to require .coffee.md files.
  at Object.base.(anonymous function) [as .coffee] (/home/baremec/.node/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:210:17)

I found a solution here : hubotio/generator-hubot#6
Conflicts:
	generators/script/templates/.travis.yml
@mtsmfm
Copy link

mtsmfm commented Jan 29, 2017

Hi, I noticed that generator-hubot generates package.json which references very old coffeescirpt.

How is the progress?

https://github.com/github/generator-hubot/blob/v0.4.0/generators/script/templates/_package.json#L29

My package (hubot-test-helper) user want to use "yield".
mtsmfm/hubot-test-helper#41 (comment)

@bkeepers
Copy link
Contributor

bkeepers commented Jun 1, 2017

We will be updating all of Hubot to plain JavaScript soon, so this issue should go away. hubotio/evolution#4

@bkeepers bkeepers closed this Jun 1, 2017
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.

None yet

5 participants