goatslacker

  • Archive
  • RSS
  • Ask me anything

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"
}
    • #coffeescript
    • #node.js
    • #travis-ci
    • #continuous integration
    • #cakefile
    • #npm
  • 3 days ago
  • 1
  • Comments
  • Permalink
  • Share
    Tweet

How to obtain harmony in your node.js

UPDATE! 3rdEden has pointed out that it’s possible to get harmony in node 0.6

You can get it by using a flag when invoking node through the command line

node --harmony_typeof --harmony_block_scoping --harmony_proxies --harmony_weakmaps file.js

Or if you’re using node 0.7.x

node --harmony file.js

Harmony!!!!1


Enable ECMAScript’s new features and syntax in node point javascript.

Node unstable has just been released and with that V8 has been upgraded to 3.8.6 which contains flags for experimental language features.

By default those flags are turned off, but you can always turn them on. Here’s how:

Download node 0.7.0.

If you’ve got it cloned on git run a git fetch and then git checkout v0.7.0 otherwise read the release notes for instructions on where to download.

Set harmony flag to true in V8

Once you’ve got the source code, open up deps/v8/src/flag-definitions.h and look for Line 115

Change the flag from false to true.

DEFINE_bool(harmony, true, "enable all harmony features")

Compile Node

./configure && make && make install

Have fun!

function foo() {
  "use strict";
  let i = -1;

  for (let i = 0; i < 10; i += 1) {
    console.log(i); // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  }

  console.log(i); // -1
}

foo();

NOTE: you’ll need to use "use strict"; otherwise the code above will not run.

By doing this you’ll get:

  • Sets, Maps, and Weak Maps
  • Block scoping
  • Proxies
  • New typeof semantics

Learn more about ES harmony

    • #ecmascript
    • #es6
    • #esnext
    • #harmony
    • #javascript
    • #node.js
    • #v8
  • 1 month ago
  • 23
  • Comments
  • Permalink
  • Share
    Tweet

Introducing gister

A nodejs module for programmatic access to create, edit and retrieve gists from github.

There are quite a few gist libraries available from npm. Most were CLI apps to create new gists, others didn’t exactly meet my needs. So I set out to create gister which provides what I think is a simple API. It follows the observer pattern and uses request to talk to GitHub.

Read the annotated source or check out the code.

Using it is really simple. Here’s how you retrieve a gist with gist_id = 1:

var gist = new Gist({ gist_id: 1 });
gist.on('get', function (data) {
  // do something with data
});
gist.get();

Creating a new gist is similar, although you’ll need to provide Gist with your GitHub username and Secret API Token which can be found in your Account Settings

var gist = new Gist({ username: 'goatslacker', token: 'abc123' });
gist.on('created', function (data, gist_id) {
  // gist_id is the newly created gist id
  // data is what github returns in it's reply
});
gist.create();

Available on npm. Install:

npm install gister
    • #cli
    • #gist
    • #github
    • #javascript
    • #node.js
    • #npm
  • 2 months ago
  • Comments
  • Permalink
  • Share
    Tweet
← Newer • Older →
Page 1 of 2

About

Software Engineering, Music, Sports
  • @goatslacker on Twitter
  • Facebook Profile
  • goatslacker on Last.fm
  • goatslacker on Grooveshark
  • Linkedin Profile
  • goatslacker on github

Twitter

loading tweets…

Posts I like

See more →
  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

Josh Perez. Effector Theme by Carlo Franco.

Powered by Tumblr