diff --git a/.travis.yml b/.travis.yml index 993d1156..3571da93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: node_js node_js: - - 0.8 - "0.10" - - "0.11" - + - 0.12 + - iojs +before_install: + - npm install -g grunt-cli notifications: email: recipients: diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 00000000..1e787fbe --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,24 @@ +'use strict'; + +module.exports = function(grunt) { + // Project configuration. + grunt.initConfig({ + jshint: { + all: ['lib/*.js', 'test/*.js', 'Gruntfile.js'], + options: { + jshintrc: '.jshintrc' + } + }, + + nodeunit: { + all: 'test/pem.js' + } + }); + + // Load the plugin(s) + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-nodeunit'); + + // Tasks + grunt.registerTask('default', ['jshint', 'nodeunit']); +}; \ No newline at end of file diff --git a/lib/pem.js b/lib/pem.js index 06a2e44f..60b6ab0d 100644 --- a/lib/pem.js +++ b/lib/pem.js @@ -1,14 +1,14 @@ 'use strict'; -var spawn = require('child_process').spawn, - os = require('os'), - pathlib = require('path'), - fs = require('fs'), - net = require('net'), - crypto = require('crypto'), - which = require('which'), - pathOpenSSL, - tempDir = process.env.PEMJS_TMPDIR || (os.tmpdir || os.tmpDir) && (os.tmpdir || os.tmpDir)() || '/tmp'; +var spawn = require('child_process').spawn; +var os = require('os'); +var pathlib = require('path'); +var fs = require('fs'); +var net = require('net'); +var crypto = require('crypto'); +var which = require('which'); +var pathOpenSSL; +var tempDir = process.env.PEMJS_TMPDIR || (os.tmpdir || os.tmpDir) && (os.tmpdir || os.tmpDir)() || '/tmp'; module.exports.createPrivateKey = createPrivateKey; module.exports.createDhparam = createDhparam; @@ -59,7 +59,7 @@ function createPrivateKey(keyBitsize, callback) { * @param {Number} [keyBitsize=512] Size of the key, defaults to 512bit * @param {Function} callback Callback function with an error object and {dhparam} */ -function createDhparam (keyBitsize, callback) { +function createDhparam(keyBitsize, callback) { if (!callback && typeof keyBitsize === 'function') { callback = keyBitsize; keyBitsize = undefined; @@ -412,20 +412,20 @@ function config(options) { * @param {Function} callback Callback function with an error object and {fingerprint} */ function getFingerprint(certificate, hash, callback) { - - if (!callback && typeof hash === 'function') { + + if (!callback && typeof hash === 'function') { callback = hash; hash = undefined; } - - hash = hash || 'sha1'; - + + hash = hash || 'sha1'; + var params = ['x509', '-in', '--TMPFILE--', '-fingerprint', '-noout', - '-'+hash + '-' + hash ]; spawnWrapper(params, certificate, function(err, code, stdout) { diff --git a/package.json b/package.json index 60b915f1..efdf9772 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,15 @@ }, "main": "lib/pem", "scripts": { - "test": "nodeunit test" + "test": "grunt" }, "dependencies": { "which": "~1.0.8" }, "devDependencies": { - "nodeunit": "*" + "grunt": "^0.4.5", + "grunt-contrib-jshint": "^0.11.0", + "grunt-contrib-nodeunit": "^0.4.1" }, "optionalDependencies": {}, "engines": { diff --git a/test/pem.js b/test/pem.js index 05853cde..1399685b 100644 --- a/test/pem.js +++ b/test/pem.js @@ -11,7 +11,7 @@ try { exports['General Tests'] = { - 'Create default sized dhparam key': function(test) { + 'Create default sized dhparam key': function(test) { pem.createDhparam(function(error, data) { var dhparam = (data && data.dhparam || '').toString(); test.ifError(error); @@ -36,7 +36,7 @@ exports['General Tests'] = { test.done(); }); }, - + 'Create default sized Private key': function(test) { pem.createPrivateKey(function(error, data) { var key = (data && data.key || '').toString();