refactor(Standalone): Remove dependency to stream-promise (#8601)

This commit is contained in:
Juanjo Diaz 2020-12-14 13:03:03 +01:00 committed by GitHub
parent ddffbc2f2d
commit ca697f3911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -3,7 +3,8 @@
const fs = require('fs');
const os = require('os');
const path = require('path');
const streamPromise = require('stream-promise');
const stream = require('stream');
const { promisify } = require('util');
const fse = require('fs-extra');
const fetch = require('node-fetch');
const currentVersion = require('../../../package').version;
@ -11,7 +12,10 @@ const isStandaloneExecutable =
require('../../utils/isStandaloneExecutable') && process.platform !== 'win32';
const standaloneUtils = require('../../utils/standalone');
const pipeline = promisify(stream.pipeline);
const BINARY_TMP_PATH = path.resolve(os.tmpdir(), 'serverless-binary-tmp');
const BINARY_PATH = standaloneUtils.path;
module.exports = class Standalone {
@ -79,7 +83,7 @@ module.exports = class Standalone {
);
}
await fse.remove(BINARY_TMP_PATH);
await streamPromise(standaloneResponse.body.pipe(fs.createWriteStream(BINARY_TMP_PATH)));
await pipeline(standaloneResponse.body, fs.createWriteStream(BINARY_TMP_PATH));
await fse.rename(BINARY_TMP_PATH, BINARY_PATH);
await fse.chmod(BINARY_PATH, 0o755);
this.serverless.cli.log(`Successfully upgraded to ${tagName}`);

View File

@ -64,7 +64,6 @@
"promise-queue": "^2.2.5",
"replaceall": "^0.1.6",
"semver": "^7.3.4",
"stream-promise": "^3.2.0",
"tabtab": "^3.0.2",
"tar": "^6.0.5",
"timers-ext": "^0.1.7",