Skip to content

Commit 759c508

Browse files
committed
fix: set user agent for octokit requests
1 parent e7fbc6c commit 759c508

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lib/loader/octokit-wrapper.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22

33
const { Octokit } = require('@octokit/rest');
44

5+
const Constants = require('../constants');
6+
57
exports.create = () => {
68

7-
const octokit = new Octokit();
9+
const octokit = new Octokit({
10+
userAgent: Constants.userAgent
11+
});
812

913
// @todo: onRateLimit
1014
// @todo: auth
11-
// @todo: user agent
1215

1316
return octokit;
1417
};

test/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,11 @@ describe('detect-node-support', () => {
594594
fixture.stubs.listRemote
595595
.returns('9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n');
596596

597-
Nock('https://api.github.com')
597+
Nock('https://api.github.com', {
598+
reqheaders: {
599+
'user-agent': /detect-node-support\/.* \(https:\/\/github.com\/pkgjs\/detect-node-support#readme\)/
600+
}
601+
})
598602
.get('/repos/pkgjs/detect-node-support/contents/package.json')
599603
.reply(200, {
600604
content: Fs.readFileSync(Path.join(__dirname, '..', 'package.json')).toString('base64')

0 commit comments

Comments
 (0)