Skip to content

Commit b756e3a

Browse files
committed
Change how upload progress is reported to prevent response breakage
1 parent 175cdf5 commit b756e3a

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/commands/deploy.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,20 @@ const formatServices = require('../util/formatServices');
1717

1818
const defaultIgnores = ['.git', 'node_modules', '.exoframeignore'];
1919

20-
const streamToResponse = ({tarStream, remoteUrl, options, verbose, handleUpload, handleDownload}) =>
20+
const streamToResponse = ({tarStream, remoteUrl, options, verbose, spinner}) =>
2121
new Promise((resolve, reject) => {
2222
// store error and result
2323
let error;
2424
let result = {};
2525
// pipe stream to remote
26-
const stream = _(
27-
tarStream.pipe(
28-
got.stream
29-
.post(remoteUrl, options)
30-
.on('uploadProgress', handleUpload)
31-
.on('downloadProgress', handleDownload)
32-
)
33-
)
26+
const stream = _(tarStream.pipe(got.stream.post(remoteUrl, options)))
3427
.split()
3528
.filter(l => l && l.length);
3629
// store output
3730
stream.on('data', str => {
31+
if (spinner) {
32+
spinner.text = 'Project uploaded! Waiting for deployment..';
33+
}
3834
const s = str.toString();
3935
try {
4036
const data = JSON.parse(s);
@@ -195,13 +191,10 @@ exports.handler = async (args = {}) => {
195191

196192
// pipe stream to remote
197193
try {
198-
const handleUpload = () => {
194+
if (spinner) {
199195
spinner.text = `Uploading project..`;
200-
};
201-
const handleDownload = () => {
202-
spinner.text = 'Project uploaded! Waiting for deployment..';
203-
};
204-
const res = await streamToResponse({tarStream, remoteUrl, options, verbose, handleUpload, handleDownload});
196+
}
197+
const res = await streamToResponse({tarStream, remoteUrl, options, verbose, spinner});
205198
// check deployments
206199
if (!res.deployments || !res.deployments.length) {
207200
const err = new Error('Something went wrong!');

test/deploy.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ test('Should display error on malformed JSON', done => {
256256
});
257257

258258
// test
259-
test('Should display verbose output', done => {
259+
test.only('Should display verbose output', done => {
260260
// spy on console
261261
const consoleSpy = sinon.spy(console, 'log');
262262

0 commit comments

Comments
 (0)