Skip to content

Commit 831ac24

Browse files
authored
Merge pull request #6 from codevor/develop
Develop
2 parents 7afddcf + 477a192 commit 831ac24

File tree

10 files changed

+63
-11
lines changed

10 files changed

+63
-11
lines changed

.eslintrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
{
2-
"extends": ["airbnb-base", "prettier"]
2+
"extends": ["airbnb-base", "prettier"],
3+
"env": {
4+
"browser": true,
5+
"es6": true,
6+
"node": true,
7+
"jest": true
8+
},
9+
"rules": {
10+
"import/prefer-default-export": "off"
11+
}
312
}

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
"description": "[![License][license-badge]][license-url]",
55
"main": "lib/index.js",
66
"scripts": {
7-
"clean": "rimraf lib dist",
8-
"build": "babel src --out-dir lib",
9-
"build:umd": "NODE_ENV=production webpack src/index.js",
10-
"lint": "eslint src",
11-
"test": "jest",
12-
"prepublish": "yarn lint && yarn test && yarn clean && yarn build && yarn build:umd"
7+
"clean": "rimraf dist",
8+
"dev": "NODE_ENV=dev webpack --progress --colors --watch",
9+
"build": "NODE_ENV=production webpack",
10+
"lint": "eslint src tests",
11+
"test": "jest --coverage --expand",
12+
"test:watch": "jest --watch",
13+
"prepublish": "yarn lint && yarn test && yarn clean && yarn build",
14+
"coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage"
1315
},
1416
"repository": {
1517
"type": "git",
@@ -28,6 +30,7 @@
2830
"@babel/preset-env": "^7.6.3",
2931
"babel-jest": "^24.9.0",
3032
"babel-loader": "^8.0.6",
33+
"coveralls": "^3.0.7",
3134
"eslint": "^6.5.1",
3235
"eslint-config-airbnb-base": "^14.0.0",
3336
"eslint-config-prettier": "^6.4.0",

src/.gitkeep

Whitespace-only changes.

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as isCreated } from './is-created';
2+
export { default as isOk } from './is-ok';

src/is-created.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function isCreated(status) {
2+
return status === 201;
3+
}
4+
5+
export default isCreated;

src/is-ok.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function isOk(status) {
2+
return status === 200;
3+
}
4+
5+
export default isOk;
File renamed without changes.

tests/is-created.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { isCreated } from '../src';
2+
3+
describe('isCreated', () => {
4+
test('it should test isCreated status equal 201', () => {
5+
expect(isCreated(201)).toBeTruthy();
6+
});
7+
8+
test('it should test isCreated status different then 200', () => {
9+
expect(isCreated(200)).toBeFalsy();
10+
});
11+
});

tests/is-ok.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { isOk } from '../src';
2+
3+
describe('isOk', () => {
4+
test('it should test isOk status equal 200', () => {
5+
expect(isOk(200)).toBeTruthy();
6+
});
7+
8+
test('it should test isOk status different then 201', () => {
9+
expect(isOk(201)).toBeFalsy();
10+
});
11+
});

webpack.config.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,35 @@ const mode = isProduction ? 'production' : 'development';
66

77
module.exports = {
88
mode,
9+
devtool: 'source-map',
910
entry: {
10-
main: path.resolve(__dirname, 'src/index.js'),
11+
app: path.resolve(__dirname, 'src/index.js')
1112
},
1213
output: {
1314
path: path.resolve(__dirname, 'dist'),
1415
filename: isProduction ? 'http-status.min.js' : 'http-status.js',
1516
library: 'HttpStatus',
1617
libraryTarget: 'umd',
18+
umdNamedDefine: true
1719
},
1820
module: {
1921
rules: [
2022
{
2123
test: /\.js$/,
2224
loader: 'babel-loader',
23-
exclude: /node_modules/,
25+
exclude: /node_modules/
2426
}
2527
]
2628
},
2729
optimization: {
2830
minimize: isProduction,
29-
minimizer: [new UglifyJsPlugin()]
31+
minimizer: [
32+
new UglifyJsPlugin({
33+
include: /\.min\.js$/
34+
})
35+
]
3036
},
3137
resolve: {
32-
extensions: [".js"]
38+
extensions: ['.js']
3339
}
3440
};

0 commit comments

Comments
 (0)