diff --git a/.travis.yml b/.travis.yml index 38834ea8..d3048fa7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,18 +1,28 @@ language: node_js -sudo: false +cache: + directories: + - node_modules node_js: - "0.10" - "0.12" - "4" - - "5" - - "iojs-v1.8" - - "iojs-v2.5" - - "iojs-v3.3" + - "6" + - "7" before_install: - npm install -g grunt-cli +before_script: + - npm prune +script: + - grunt +after_success: + - npm run semantic-release +branches: + except: + - /^v\d+\.\d+\.\d+$/ notifications: email: recipients: - github@josef-froehle.de on_success: change on_failure: change + diff --git a/lib/pem.js b/lib/pem.js index db147fc7..ea16d8f4 100644 --- a/lib/pem.js +++ b/lib/pem.js @@ -72,16 +72,24 @@ function createPrivateKey(keyBitsize, options, callback) { params.push(keyBitsize); - execOpenSSL(params, 'RSA PRIVATE KEY', function(error, key) { - if(clientKeyPassword) { - fs.unlink(clientKeyPassword, function() {}); + execOpenSSL(params, 'RSA PRIVATE KEY', function(sslErr, key) { + function done(err) { + if (err) { + return callback(err); + } + callback(null, { + key: key + }); } - if (error) { - return callback(error); + + if (clientKeyPassword) { + fs.unlink(clientKeyPassword, function(fsErr) { + done(sslErr || fsErr); + }); + } + else { + done(sslErr); } - return callback(null, { - key: key - }); }); } @@ -217,20 +225,25 @@ function createCSR(options, callback) { params.push('file:' + passwordFilePath); } - execOpenSSL(params, 'CERTIFICATE REQUEST', tmpfiles, function(error, data) { + execOpenSSL(params, 'CERTIFICATE REQUEST', tmpfiles, function(sslErr, data) { + function done(err) { + if (err) { + return callback(err); + } + callback(null, { + csr: data, + config: config, + clientKey: options.clientKey + }); + } if (passwordFilePath) { - fs.unlink(passwordFilePath); + fs.unlink(passwordFilePath, function (fsErr) { + done(sslErr || fsErr); + }); } - if (error) { - return callback(error); + else { + done(sslErr); } - var response = { - csr: data, - config: config, - clientKey: options.clientKey - }; - return callback(null, response); - }); } @@ -1002,7 +1015,7 @@ function spawnWrapper(params, tmpfiles, binary, callback) { spawnOpenSSL(params, binary, function(err, code, stdout, stderr) { files.forEach(function(file) { - fs.unlink(file.path); + fs.unlinkSync(file.path); }); callback(err, code, stdout, stderr); }); diff --git a/package.json b/package.json index e59bfc3a..d2da374a 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,15 @@ ], "name": "pem", "description": "Create private keys and certificates with node.js and io.js", - "version": "1.8.3", + "version": "1.9.1", "repository": { "type": "git", - "url": "git://github.com/andris9/pem.git" + "url": "https://github.com/Dexus/pem.git" }, "main": "lib/pem", "scripts": { - "test": "grunt" + "test": "grunt", + "semantic-release": "semantic-release pre && npm publish && semantic-release post" }, "dependencies": { "os-tmpdir": "^1.0.1", @@ -26,11 +27,19 @@ "grunt": "^0.4.5", "grunt-contrib-jshint": "^0.11.3", "grunt-contrib-nodeunit": "^0.4.1", - "nodeunit": "^0.9.1" + "nodeunit": "^0.9.1", + "semantic-release": "^6.3.2", + "semantic-release-tamia": "^1.0.0" }, "optionalDependencies": {}, "engines": { "node": "*", "iojs": "*" + }, + "release": { + "analyzeCommits": "semantic-release-tamia/analyzeCommits", + "generateNotes": "semantic-release-tamia/generateNotes", + "verifyRelease": "semantic-release-tamia/verifyRelease", + "verifyConditions": "./" } }