Skip to content

Commit

Permalink
add dynamic version
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmueller committed Feb 5, 2012
1 parent 948629d commit 41337f9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
exports = module.exports = require('./lib/cheerio');
exports.parse = require('./lib/parse');
exports.render = require('./lib/render');
exports.utils = require('./lib/utils');
exports.utils = require('./lib/utils');

/*
Export the version
*/
var version = function() {
var pkg = require('fs').readFileSync(__dirname + '/package.json', 'utf8');
return JSON.parse(pkg).version;
};
exports.__defineGetter__('version', version);
2 changes: 1 addition & 1 deletion lib/cheerio.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var cheerio = (function() {
var quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/;

cheerio.fn = cheerio.prototype = {
cheerio : '0.4.2',
cheerio : '[cheerio object]',
constructor : cheerio,
init : function(selector, context, root) {
// Handle $(''), $(null), and $(undefined)
Expand Down
3 changes: 3 additions & 0 deletions test/cheerio.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ multiclass = '<p><a class = "btn primary" href = "#">Save</a></p>'

describe 'cheerio', ->

it 'should get the version', ->
/\d\.\d\.\d/.test($.version).should.be.ok

it '$(null) should return be empty', ->
$(null).should.be.empty

Expand Down

0 comments on commit 41337f9

Please sign in to comment.