From 72a8d2ef2d7f6c88e6cba3c1938a4d4f8dc0fae7 Mon Sep 17 00:00:00 2001 From: Stephen Murphy Date: Mon, 11 Mar 2013 14:43:22 -0700 Subject: [PATCH] added istanbul code coverage and bumped deps --- .gitignore | 4 +++- Makefile | 16 +++++++++++++++- index.js | 2 +- lib/s3.js | 10 +--------- package.json | 16 +++++++++------- test/csslint.js | 2 +- test/cssminify.js | 4 ++-- test/glob.js | 2 +- test/handlebars.js | 2 +- test/jslint.js | 2 +- test/jsminify.js | 2 +- test/replace.js | 2 +- test/s3.js | 13 +++++-------- test/stamp.js | 2 +- 14 files changed, 43 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 969a4c5..61a6aa6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ node_modules -testing \ No newline at end of file +testing +lib-cov +html-report \ No newline at end of file diff --git a/Makefile b/Makefile index 75a210f..f22b8c2 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ -all: bootstrap test +BIN = ./node_modules/.bin + +all: bootstrap test coverage bootstrap: node bootstrap.js @@ -6,4 +8,16 @@ bootstrap: test: npm test +coverage: lib-cov + @COVER=1 $(BIN)/mocha --require should --reporter mocha-istanbul + +lib-cov: + @$(BIN)/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib + +clean: clean-coverage + +clean-coverage: + -rm -rf lib-cov + -rm -rf html-report + .PHONY: test \ No newline at end of file diff --git a/index.js b/index.js index a0126f9..83e14ac 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ * See the accompanying LICENSE file for terms. */ var fs = require('fs'), - path = __dirname + '/lib/', + path = __dirname + (process.env.COVER ? '/lib-cov/' : '/lib/'), tasks = fs.readdirSync(path).filter(function(file) {return file.substr(-3) === '.js';}); tasks.forEach(function(task) { diff --git a/lib/s3.js b/lib/s3.js index 252afe6..00f768b 100644 --- a/lib/s3.js +++ b/lib/s3.js @@ -4,11 +4,10 @@ * See the accompanying LICENSE file for terms. */ var knox = require('knox'), - Crypto = require('crypto'), mime = require('mime'); /** - * Send blob to S3 with an optional checksum in the filename. + * Send blob to S3. * * @param options {Object} S3 task options. * @param options.name {String} Resource name. @@ -21,18 +20,11 @@ var s3 = exports.s3 = function s3(options, blob, done) { name = options.name, result, client, - checksum, req; result = blob.result; client = knox.createClient(options.client); - if (name.indexOf('{checksum}') > -1) { // Replace {checksum} with md5 string - checksum = Crypto.createHash('md5'); - checksum.update(result); - name = name.replace('{checksum}', checksum.digest('hex')); - } - req = client.put(name, {'Content-Length': result.length, 'Content-Type': mime.lookup(name)}); req.on('response', function (res) { diff --git a/package.json b/package.json index a37cc1f..bc43b38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gear-lib", - "version": "0.8.7", + "version": "0.8.8", "description": "Collection of common Gear.js tasks", "author": "Stephen Murphy ", "keywords": ["gear", "task", "build"], @@ -13,17 +13,19 @@ "dependencies": { "gear": ">= 0.8.x", "jslint": "0.1.x", - "uglify-js": "1.2.x", + "uglify-js": "1.3.x", "csslint": "0.9.x", - "less": "1.2.x", + "less": "1.3.x", "handlebars": "1.0.x", "mime": "1.2.x", - "knox": "0.0.x", - "async": "0.1.x", + "knox": "0.5.x", + "async": "0.2.x", "glob": "3.1.x" }, "devDependencies": { - "should": "1.2.x", - "mocha": "1.7.x" + "should": "*", + "mocha": "*", + "mocha-istanbul": "*", + "istanbul": "*" } } diff --git a/test/csslint.js b/test/csslint.js index 017c061..6f5cc9a 100644 --- a/test/csslint.js +++ b/test/csslint.js @@ -1,6 +1,6 @@ var should = require('should'), Blob = require('gear').Blob, - csslint = require('../lib/csslint').csslint, + csslint = require('..').csslint, fixtures = { invalid: new Blob('%%%%'), options: new Blob('.foo {width: 0; width: 0;}') diff --git a/test/cssminify.js b/test/cssminify.js index 3c2c87c..0b054e2 100644 --- a/test/cssminify.js +++ b/test/cssminify.js @@ -1,6 +1,6 @@ var Blob = require('gear').Blob, - cssminify = require('../lib/cssminify').cssminify, - less = require('../lib/cssminify').less, + cssminify = require('..').cssminify, + less = require('..').less, fixtures = { css: new Blob(' .bar { display: none; } '), min: '.bar{display:none;}\n', diff --git a/test/glob.js b/test/glob.js index 0ae9fa6..f61d763 100644 --- a/test/glob.js +++ b/test/glob.js @@ -1,7 +1,7 @@ var should = require('should'), Queue = require('gear').Queue, Registry = require('gear').Registry, - glob = require('../lib/glob').glob, + glob = require('..').glob, fixtures = { options: {pattern: 'ind*.js'}, expected: 'index.js' diff --git a/test/handlebars.js b/test/handlebars.js index 5af5ba3..99637c6 100644 --- a/test/handlebars.js +++ b/test/handlebars.js @@ -1,5 +1,5 @@ var Blob = require('gear').Blob, - handlebars = require('../lib/handlebars').handlebars, + handlebars = require('..').handlebars, fixtures = { tmpl: new Blob('test:{{test}}') }; diff --git a/test/jslint.js b/test/jslint.js index 11de8f1..8755038 100644 --- a/test/jslint.js +++ b/test/jslint.js @@ -1,5 +1,5 @@ var Blob = require('gear').Blob, - jslint = require('../lib/jslint').jslint, + jslint = require('..').jslint, fixtures = { invalid: new Blob('^^^^'), options: new Blob('function _blah() {}') diff --git a/test/jsminify.js b/test/jsminify.js index 515b38f..fa1d05a 100644 --- a/test/jsminify.js +++ b/test/jsminify.js @@ -1,5 +1,5 @@ var Blob = require('gear').Blob, - jsminify = require('../lib/jsminify').jsminify, + jsminify = require('..').jsminify, fixtures = { js: new Blob('function test( x ) {console.log(x);;;;}'), min: 'function test(x){console.log(x);}\n', diff --git a/test/replace.js b/test/replace.js index 913f029..4f8ac1e 100644 --- a/test/replace.js +++ b/test/replace.js @@ -1,5 +1,5 @@ var Blob = require('gear').Blob, - replace = require('../lib/replace').replace, + replace = require('..').replace, fixtures = { js: new Blob("function (x) { Y.log('REMOVEME');}"), replaced: "function (x) { }", diff --git a/test/s3.js b/test/s3.js index 85c6ad1..c41b6af 100644 --- a/test/s3.js +++ b/test/s3.js @@ -1,5 +1,6 @@ var Blob = require('gear').Blob, - s3 = require('../lib/s3').s3, + s3 = require('..').s3, + should = require('should'), fixtures = { options: { name: 'test.js', @@ -12,15 +13,11 @@ var Blob = require('gear').Blob, js: new Blob('function test( x ) {console.log(x);;;;}') }; -/* describe('s3()', function() { - // Travis CI can't write to S3 it('should deploy to s3', function(done) { s3(fixtures.options, fixtures.js, function(err, results) { - done(err); + should.exist(err); // Travis CI can't write to S3 + done(); }); }); - - it('should replace {checksum} in filename'); -}); -*/ \ No newline at end of file +}); \ No newline at end of file diff --git a/test/stamp.js b/test/stamp.js index 25938b0..d08b796 100644 --- a/test/stamp.js +++ b/test/stamp.js @@ -1,5 +1,5 @@ var Blob = require('gear').Blob, - stamp = require('../lib/stamp').stamp, + stamp = require('..').stamp, fixtures = { prefix: 'function() {\n', postfix: '\n}\n',