Replace deprecated request
guimard opened this issue · 4 comments
guimard commented
Hi,
request
is deprecated. One way to replace it could be to use node-fetch:
--- a/lib/sendToCoveralls.js
+++ b/lib/sendToCoveralls.js
@@ -1,6 +1,6 @@
'use strict';
-const request = require('request');
+const fetch = require('node-fetch');
const index = require('..');
const sendToCoveralls = (obj, cb) => {
@@ -16,13 +16,14 @@
process.stdout.write(str);
cb(null, { statusCode: 200 }, '');
} else {
- request.post({
- url,
- form: {
- json: str
- }
- }, (err, response, body) => {
- cb(err, response, body);
+ fetch(url, {
+ method: "post",
+ body: str,
+ headers: { 'Content-Type': 'application/json' },
+ }).then(res => {
+ cb(null, res, res.body);
+ }).catch(err => {
+ cb(err);
});
}
};
Of course, test must be updated also
jtwebman commented
I also forked this repo as it had been a few months with no response and used GOT as well as fixed all the other warnings here: https://github.com/jtwebman/coveralls-next
AndreMaz commented
Hi @nickmerwin any chance of making this happen? #311 seems to solve the issue
jtwebman commented
Since this library doesn't seem to be supported anymore I fix a bunch of things on a fork if you want to check it out and are still pulling the library into your packages: https://github.com/jtwebman/coveralls-next