Skip to content

Commit e0d05c5

Browse files
committed
fix(import): remove usage of stream.finished
- stream.finished wasn't added until node v10
1 parent 7e1db00 commit e0d05c5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/tasks/import/api.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
const fs = require('fs-extra');
22
const got = require('got');
33
const get = require('lodash/get');
4-
const util = require('util');
5-
const stream = require('stream');
64
const semver = require('semver');
75
const FormData = require('form-data');
86
const {Cookie} = require('tough-cookie');
97

10-
const finished = util.promisify(stream.finished);
11-
128
const {SystemError} = require('../../errors');
139

1410
const bases = {
@@ -103,10 +99,12 @@ async function runImport(version, url, auth, exportFile) {
10399
async function downloadExport(version, url, auth, outputFile) {
104100
const authOpts = await getAuthOpts(version, url, auth);
105101

106-
const ws = fs.createWriteStream(outputFile);
107-
const resp = got.stream('/db/', {...authOpts}).pipe(ws);
102+
await new Promise((resolve, reject) => {
103+
const ws = fs.createWriteStream(outputFile);
104+
const resp = got.stream('/db/', {...authOpts}).pipe(ws);
108105

109-
await finished(resp);
106+
resp.on('finish', () => resolve()).on('error', reject);
107+
});
110108
}
111109

112110
module.exports = {

0 commit comments

Comments
 (0)