nickmerwin / node-coveralls

lcov posting to coveralls.io
Other
1.07k stars 258 forks source link

Replace deprecated request #309

Open guimard opened 3 years ago

guimard commented 3 years ago

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 3 years ago

I did it here with got library: https://github.com/nickmerwin/node-coveralls/pull/311

jtwebman commented 3 years ago

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 2 years ago

Hi @nickmerwin any chance of making this happen? https://github.com/nickmerwin/node-coveralls/pull/311 seems to solve the issue

jtwebman commented 2 years ago

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