Skip to content
This repository was archived by the owner on Sep 27, 2021. It is now read-only.

Commit 8923de0

Browse files
committed
handle stream properly
1 parent d30c76c commit 8923de0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/rclone.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ module.exports = {
1616
}));
1717
},
1818

19-
cat(path) {
19+
cat(path, stream = true) {
2020
const args = [
2121
'cat',
2222
path
2323
];
2424

25-
return execa(binaryPath, args).stdout;
25+
const process = execa(binaryPath, args);
26+
27+
return stream === true
28+
? process.stdout
29+
: process.then(({stdout}) => stdout);
2630
},
2731

2832
cp(file, dest) {

server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ router.get('/user/:user/repos', async ctx => {
5555
router.get('/user/:user/json', async ctx => {
5656
ctx.set('Content-Type', 'application/json');
5757

58-
const raw = await rclone.cat(`${pathing.encode(ctx.params.user)}.json`);
58+
const raw = await rclone.cat(`${pathing.encode(ctx.params.user)}.json`, false);
5959

6060
ctx.body = JSON.stringify(raw, null, '\t');
6161
});

0 commit comments

Comments
 (0)