Skip to content

Commit 3e9cb28

Browse files
compwrightJonathon Hill
authored andcommitted
chore(build): Build to ES5
1 parent f3cb010 commit 3e9cb28

File tree

8 files changed

+6020
-542
lines changed

8 files changed

+6020
-542
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ language: node_js
33
node_js:
44
- 8
55
- 10
6+
- 12

dist/.gitignore

Whitespace-only changes.

package-lock.json

Lines changed: 5957 additions & 516 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
"name": "axios-oauth-client",
33
"version": "1.2.3",
44
"description": "OAuth 2.0 client utils for axios",
5-
"main": "src/",
6-
"scripts": {
7-
"test": "mocha tests/ --timeout 10000"
8-
},
5+
"main": "dist/",
96
"author": "Jonathon Hill <jhill9693@gmail.com>",
107
"license": "MIT",
118
"directories": {
@@ -28,11 +25,50 @@
2825
"engines": {
2926
"node": ">=8"
3027
},
28+
"scripts": {
29+
"publish": "git push origin --tags && npm run changelog && git push origin",
30+
"release:pre": "npm run dist && npm version prerelease && npm publish --tag pre",
31+
"release:patch": "npm run dist && npm version patch && npm publish",
32+
"release:minor": "npm run dist && npm version minor && npm publish",
33+
"release:major": "npm run dist && npm version major && npm publish",
34+
"changelog": "github_changelog_generator && git add CHANGELOG.md && git commit -am \"Updating changelog\"",
35+
"dist": "npm run build && git commit -am \"Updating build\"",
36+
"build": "babel src -d dist",
37+
"pretest": "semistandard src/*.js src/**/*.js tests/*.js tests/**/*.js --fix",
38+
"test": "nyc mocha tests/ --timeout 10000"
39+
},
40+
"babel": {
41+
"presets": [
42+
"@babel/preset-env"
43+
]
44+
},
45+
"semistandard": {
46+
"env": [
47+
"mocha"
48+
]
49+
},
50+
"nyc": {
51+
"cache": true,
52+
"cacheDir": ".nyc_cache",
53+
"include": [
54+
"lib/**/*.js"
55+
],
56+
"reporter": [
57+
"lcov",
58+
"text-summary"
59+
]
60+
},
61+
"browserslist": "> 0.25%, not dead",
3162
"dependencies": {
3263
"qs": "^6.8.0"
3364
},
3465
"devDependencies": {
66+
"@babel/cli": "^7.5.5",
67+
"@babel/core": "^7.5.5",
68+
"@babel/preset-env": "^7.5.5",
3569
"axios-token-interceptor": "^0.2.0",
36-
"mocha": "^7.1.0"
70+
"mocha": "^7.1.1",
71+
"nyc": "^15.0.0",
72+
"semistandard": "^14.2.0"
3773
}
3874
}

src/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const qs = require('qs');
22

3-
module.exports = function(axios, { url, ...credentials }) {
3+
module.exports = function (axios, { url, ...credentials }) {
44
const config = {
55
url,
66
method: 'post',

src/interceptor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
function getMaxAge(res) {
1+
function getMaxAge (res) {
22
return res.expires_in;
33
}
44

5-
function headerFormatter(res) {
5+
function headerFormatter (res) {
66
return 'Bearer ' + res.access_token;
77
}
88

tests/client.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('client()', function () {
1919

2020
const axios = async function (config) {
2121
const { url, ...data } = params;
22-
assert.deepEqual(config, {
22+
assert.deepStrictEqual(config, {
2323
url,
2424
method: 'post',
2525
data: qs.stringify(data)
@@ -30,12 +30,12 @@ describe('client()', function () {
3030
const auth = client(axios, params);
3131
assert.strictEqual(await auth(), true);
3232
});
33-
33+
3434
it('should resolve to the OAuth token response', async function () {
3535
const data = { access_token: 'FAKE_TOKEN', expires_in: 5 };
3636
const axios = async () => ({ data });
3737
const auth = client(axios, {});
38-
assert.deepEqual(await auth(), data);
38+
assert.deepStrictEqual(await auth(), data);
3939
});
4040
});
4141
});

tests/interceptor.test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,54 @@ const assert = require('assert');
22
const tokenProvider = require('axios-token-interceptor');
33
const interceptor = require('../src/interceptor');
44

5-
describe('interceptor', function() {
6-
it('should return an axios request interceptor function', function() {
5+
describe('interceptor', function () {
6+
it('should return an axios request interceptor function', function () {
77
assert.strictEqual(typeof interceptor(tokenProvider), 'function');
88
});
99

10-
describe('the axios request interceptor function', function() {
11-
it('should set the oauth access token in the request authorization header with the bearer scheme', async function() {
12-
const authenticate = async() => ({
10+
describe('the axios request interceptor function', function () {
11+
it('should set the oauth access token in the request authorization header with the bearer scheme', async function () {
12+
const authenticate = async () => ({
1313
access_token: 'foo',
1414
expires_in: 0
1515
});
1616
const newRequest = await interceptor(tokenProvider, authenticate)({
1717
headers: {}
1818
});
19-
assert.deepEqual(newRequest, {
19+
assert.deepStrictEqual(newRequest, {
2020
headers: {
2121
Authorization: 'Bearer foo'
2222
}
2323
});
2424
});
2525

26-
it('should cache the oauth access token until it expires', async function() {
27-
function delay(ms) {
26+
it('should cache the oauth access token until it expires', async function () {
27+
function delay (ms) {
2828
return new Promise((resolve, reject) => setTimeout(resolve, ms));
2929
}
3030

3131
let calls = 0;
32-
const authenticate = async() => {
32+
const authenticate = async () => {
3333
return {
3434
access_token: 'foo' + calls++,
3535
expires_in: 2
36-
}
36+
};
3737
};
3838

3939
const req = { headers: {} };
4040
const requestInterceptor = interceptor(tokenProvider, authenticate);
4141

42-
function test3x(req) {
42+
function test3x (req) {
4343
return Promise.all([
4444
requestInterceptor(req),
4545
requestInterceptor(req),
4646
requestInterceptor(req)
47-
])
47+
]);
4848
}
4949

50-
function verify(results, expected) {
51-
for (let result of results) {
52-
assert.deepEqual(result, expected);
50+
function verify (results, expected) {
51+
for (const result of results) {
52+
assert.deepStrictEqual(result, expected);
5353
}
5454
}
5555

0 commit comments

Comments
 (0)