Adding a CoffeeScript project to Travis-CI
Say you have this project you wrote in CoffeeScript and you want to add it to Travis-CI
but you do not want to include the compiled output in your code repository. Well, you will need to tell Travis to compile your project first before running the tests otherwise they would fail.
But how?
Add this to your .travis.yml
before_script:
coffee -c -o lib src
Commands under before_script run before the unit tests are ran. So use CoffeeScript to compile your project before running the tests.
You will obviously need coffee-script as a dev_dependency in your package.json
"devDependencies": {
"coffee-script": "latest"
}
Alternatively you can just use this Cakefile and add the following to your package.json instead
"scripts": {
"test": "cake test"
}
On case against coffeescript...
There are basically a few arguments against using CoffeeScript and at the end of the article Ryan Florence suggests one to not use it. It basically boils down to these cases:
- Debugging is an issue
- Verbally Readable !== Quicker Comprehension
- One liners are horrible
- CoffeeScript has it’s bad parts
- Significant whitespace + Spaghetti code is bad
- CoffeeScript will never be supported natively.
Debugging is an issue
So yes, debugging is an issue. Hopefully this can be solved soon by SourceMap.
Verbally Readable does not mean Quicker Comprehension.
I agree, in fact I comprehend Verbally Readable !== Quicker Comprehension quicker than I do the title. But the nice thing about CoffeeScript is that it’s just JavaScript so the lengthy wordy operators are optional.
You could always write in CoffeeScript:
one && two && three
instead of
one and two and three
One liners are horrible
Here’s an example from the blog:
scores = (student["assignment_#{@assignment.id}"].score for own idx, student of @gradebook.students when student["assignment_#{@assignment.id}"]?.score?)
Right, that’s not easy to comprehend. In this particular case I don’t blame the language but the author.
Sure the CoffeeScript documentation touts how it turns verbose JavaScript into “nice” and “sexy” one-liners but that doesn’t mean one should abuse it.
CoffeeScript has it’s bad parts
So does every other language. I think the good parts of the language outweigh the bad parts.
Significant whitespace + spaghetti code is bad
Spaghetti code itself is bad. I don’t care what language you write it in. It’ll always look like shit.
It seems like now we’re talking about preferring one type of spaghetti over another type of spaghetti — it’s still spaghetti.
CoffeeScript will never be supported natively
Is that really a bad thing?
Overall
I still believe the expressiveness and useful features that CoffeeScript provides outweighs the biggest problem which is debugging.
Hash - Throwaway passwords
Staying secure online is a difficult task.
When you sign up for a service, you’re giving someone your password so recycling passwords is usually a bad idea. If you use the same password everywhere all it takes is one security breach.
But, managing an entire drawer of passwords is really difficult. There are solutions available both online and natively that allow you to manage multiple passwords, but I’ve yet to come accross a solution that works everywhere and I feel ok about it.
So this afternoon I created this web application which will take a domain name, and a master password and return you a hash. The password is generated on your computer using JavaScript so nothing is sent over the network. You can then use the hash, or part of the hash, as your password. There is also a bookmarklet available which automatically detects password fields and fills them in for you.
This isn’t 100% bulletproof as there are still other ways you may be attacked like phishing and keyloggers, but at least it’s better than recycling passwords or trying to remember a dozen different passwords.
The site is built with Twitter’s Bootstrap library and uses Stanford’s JavaScript Cryptography Library the app itself is built in CoffeeScript.
Give it a whirl and I’d appreciate some feedback.