chore(fs/abstract#_outputFile): use readable-stream/finished

This commit is contained in:
Julien Fontanet 2018-12-05 11:00:12 +01:00
parent d617214c62
commit f6b73b8303

View File

@ -3,6 +3,7 @@
// $FlowFixMe
import asyncMap from '@xen-orchestra/async-map'
import getStream from 'get-stream'
import { finished } from 'readable-stream'
import { fromCallback, fromEvent, ignoreErrors, timeout } from 'promise-toolbox'
import { parse } from 'xo-remote-parser'
import { randomBytes } from 'crypto'
@ -104,10 +105,10 @@ export default class RemoteHandlerAbstract {
}
async _outputFile(file: string, data: Data, options?: Object): Promise<void> {
const stream = await this.createOutputStream(normalizePath(file), options)
const promise = fromEvent(stream, 'finish')
const stream = await this.createOutputStream(file, options)
const promise = fromCallback(cb => finished(stream))
stream.end(data)
await promise
return promise
}
async read(