Skip to content

Commit

Permalink
added istanbul code coverage and bumped deps
Browse files Browse the repository at this point in the history
  • Loading branch information
twobit committed Mar 11, 2013
1 parent 6644467 commit 72a8d2e
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 36 deletions.
4 changes: 3 additions & 1 deletion .gitignore
@@ -1,2 +1,4 @@
node_modules
testing
testing
lib-cov
html-report
16 changes: 15 additions & 1 deletion Makefile
@@ -1,9 +1,23 @@
all: bootstrap test
BIN = ./node_modules/.bin

all: bootstrap test coverage

bootstrap:
node bootstrap.js

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
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -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) {
Expand Down
10 changes: 1 addition & 9 deletions lib/s3.js
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down
16 changes: 9 additions & 7 deletions 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 <stephen@hypernaut.com>",
"keywords": ["gear", "task", "build"],
Expand All @@ -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": "*"
}
}
2 changes: 1 addition & 1 deletion 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;}')
Expand Down
4 changes: 2 additions & 2 deletions 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',
Expand Down
2 changes: 1 addition & 1 deletion 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'
Expand Down
2 changes: 1 addition & 1 deletion 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}}')
};
Expand Down
2 changes: 1 addition & 1 deletion 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() {}')
Expand Down
2 changes: 1 addition & 1 deletion 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',
Expand Down
2 changes: 1 addition & 1 deletion 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) { }",
Expand Down
13 changes: 5 additions & 8 deletions 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',
Expand All @@ -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');
});
*/
});
2 changes: 1 addition & 1 deletion 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',
Expand Down

0 comments on commit 72a8d2e

Please sign in to comment.