-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from elliotttf/semantic-release
chore(semantic-release): Adding semantic release
- Loading branch information
Showing
7 changed files
with
109 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# node_modules ignored by default | ||
|
||
# Ignore generated files | ||
coverage | ||
newrelic.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"parserOptions": { | ||
"ecmaVersion": 6, | ||
"sourceType": "script" | ||
}, | ||
"extends": "airbnb-base", | ||
"rules": { | ||
"brace-style": ["error", "stroustrup"], | ||
"max-len": ["warn", { | ||
"code": 100, | ||
"comments": 80, | ||
"ignoreUrls": true, | ||
"ignorePattern": "(logger\\.|new Error\\)|new TypeError\\()", | ||
"ignoreTrailingComments": true, | ||
"tabWidth": 2 | ||
}], | ||
"no-warning-comments": "warn", | ||
"quotes": ["error", "single", {"avoidEscape": true, "allowTemplateLiterals": true}], | ||
"require-jsdoc": ["error", { | ||
"require": { | ||
"FunctionDeclaration": true, | ||
"MethodDefinition": true, | ||
"ClassDeclaration": true | ||
} | ||
}], | ||
"valid-jsdoc": "error" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
language: node_js | ||
sudo: false | ||
language: node_js | ||
cache: | ||
directories: | ||
- node_modules | ||
notifications: | ||
email: false | ||
node_js: | ||
- "0.12" | ||
- "4" | ||
- "node" | ||
script: npm test && npm run coverage | ||
after_success: npm run coveralls | ||
|
||
- '6' | ||
before_install: | ||
- npm i -g npm@^2.0.0 | ||
before_script: | ||
- npm prune | ||
script: npm run lint && npm t | ||
after_success: | ||
- npm run coveralls | ||
- npm run semantic-release | ||
branches: | ||
except: | ||
- /^v\d+\.\d+\.\d+$/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
{ | ||
"name": "express-conditional-middleware", | ||
"version": "1.1.2", | ||
"description": "Allow express middlewares to be overridden based on a condition.", | ||
"repository": "https://github.com/elliotttf/express-conditional-middleware", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/elliotttf/express-conditional-middleware.git" | ||
}, | ||
"main": "lib/conditional.js", | ||
"scripts": { | ||
"test": "istanbul cover --print both nodeunit ./test/index.js", | ||
"lint": "eslint .", | ||
"coverage": "istanbul check-coverage --statements 100 --lines 100 --branches 100 --functions 100", | ||
"coveralls": "cat ./coverage/lcov.info | coveralls" | ||
"coveralls": "cat ./coverage/lcov.info | coveralls", | ||
"semantic-release": "semantic-release pre && npm publish && semantic-release post" | ||
}, | ||
"author": "Elliott Foster <[email protected]> (http://codebrews.com/)", | ||
"license": "MIT", | ||
|
@@ -17,10 +20,13 @@ | |
}, | ||
"devDependencies": { | ||
"coveralls": "^2.11.6", | ||
"eslint": "^2.2.0 <3", | ||
"eslint": "^3.9.1", | ||
"eslint-config-airbnb-base": "^10.0.1", | ||
"eslint-plugin-import": "^2.2.0", | ||
"ghooks": "^1.2.4", | ||
"istanbul": "^0.4.2", | ||
"nodeunit": "^0.10.2" | ||
"nodeunit": "^0.10.2", | ||
"semantic-release": "^4.3.5" | ||
}, | ||
"config": { | ||
"ghooks": { | ||
|
@@ -29,6 +35,6 @@ | |
} | ||
}, | ||
"engines": { | ||
"node": ">=0.12" | ||
"node": ">=6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,85 @@ | ||
var conditional = require('../lib/conditional.js'); | ||
'use strict'; | ||
|
||
const conditional = require('../lib/conditional.js'); | ||
|
||
module.exports = { | ||
bool: function (test) { | ||
bool(test) { | ||
test.expect(3); | ||
|
||
var middleware = conditional(true, function () { | ||
let middleware = conditional(true, () => { | ||
test.ok(true, 'true conditional worked.'); | ||
}); | ||
|
||
middleware({}, {}, function () { | ||
middleware({}, {}, () => { | ||
test.done(); | ||
}); | ||
|
||
middleware = conditional(false, function () { | ||
middleware = conditional(false, () => { | ||
test.done(); | ||
}); | ||
|
||
middleware({}, {}, function () { | ||
middleware({}, {}, () => { | ||
test.ok(true, 'false conditional worked.'); | ||
}); | ||
|
||
middleware = conditional(false, function () { | ||
middleware = conditional(false, () => { | ||
test.done(); | ||
}, function () { | ||
}, () => { | ||
test.ok(true, 'fail conditional worked.'); | ||
test.done(); | ||
}); | ||
|
||
middleware({}, {}, function () { | ||
middleware({}, {}, () => { | ||
test.done(); | ||
}); | ||
}, | ||
|
||
func: function (test) { | ||
func(test) { | ||
test.expect(3); | ||
|
||
var conditionFunc = function (req) { | ||
return req.working === true; | ||
}; | ||
const conditionFunc = req => req.working === true; | ||
|
||
var middleware = conditional( | ||
conditionFunc, | ||
function () { | ||
test.ok(true, 'Conditional function returned true.'); | ||
} | ||
); | ||
let middleware = conditional(conditionFunc, () => test.ok(true, | ||
'Conditional function returned true.')); | ||
|
||
middleware({working: true}, {}, function () { | ||
test.done(); | ||
}); | ||
middleware({ working: true }, {}, () => test.done()); | ||
|
||
middleware = conditional( | ||
conditionFunc, | ||
function () { | ||
test.done(); | ||
} | ||
); | ||
middleware = conditional(conditionFunc, () => test.done()); | ||
|
||
middleware({working: false}, {}, function () { | ||
middleware({ working: false }, {}, () => { | ||
test.ok(true, 'Conditional function returned false.'); | ||
}); | ||
|
||
middleware = conditional( | ||
conditionFunc, | ||
function () { | ||
test.done(); | ||
}, | ||
function () { | ||
test.ok(true, 'Conditional function returned false, executed otherwise.'); | ||
test.done(); | ||
} | ||
); | ||
|
||
middleware({working: false}, {}, function () { | ||
middleware = conditional(conditionFunc, () => test.done(), () => { | ||
test.ok(true, 'Conditional function returned false, executed otherwise.'); | ||
test.done(); | ||
}); | ||
|
||
middleware({ working: false }, {}, () => { | ||
test.done(); | ||
}); | ||
}, | ||
|
||
funcOnce: function (test) { | ||
funcOnce(test) { | ||
test.expect(2); | ||
|
||
var count = 0; | ||
let count = 0; | ||
|
||
var conditionFunc = function (req, res, next) { | ||
const conditionFunc = (req, res, next) => { | ||
next(); | ||
return true; | ||
}; | ||
|
||
var middleware = conditional( | ||
conditionFunc, | ||
function (req, res, next) { | ||
test.ok(true, 'Conditional executed.'); | ||
next(); | ||
test.done(); | ||
} | ||
); | ||
|
||
middleware({}, {}, function () { | ||
count++; | ||
const middleware = conditional(conditionFunc, (req, res, next) => { | ||
test.ok(true, 'Conditional executed.'); | ||
next(); | ||
test.done(); | ||
}); | ||
|
||
middleware({}, {}, () => { | ||
count += 1; | ||
test.equal(count, 1, 'Middleware only executed once.'); | ||
}); | ||
} | ||
}, | ||
}; | ||
|