chore(xo-server): replace eventToPromise with fromEvent
This commit is contained in:
parent
b7d3762c06
commit
3e89c62e72
@ -1,6 +1,5 @@
|
||||
import eventToPromise from 'event-to-promise'
|
||||
import through2 from 'through2'
|
||||
import { ignoreErrors } from 'promise-toolbox'
|
||||
import { fromEvent, ignoreErrors } from 'promise-toolbox'
|
||||
import { parse } from 'xo-remote-parser'
|
||||
|
||||
import { getPseudoRandomBytes, streamToBuffer } from '../utils'
|
||||
@ -78,7 +77,7 @@ export default class RemoteHandlerAbstract {
|
||||
|
||||
async _outputFile (file, data, options) {
|
||||
const stream = await this.createOutputStream(file, options)
|
||||
const promise = eventToPromise(stream, 'finish')
|
||||
const promise = fromEvent(stream, 'finish')
|
||||
stream.end(data)
|
||||
return promise
|
||||
}
|
||||
@ -121,7 +120,7 @@ export default class RemoteHandlerAbstract {
|
||||
const path = typeof file === 'string' ? file : file.path
|
||||
const streamP = this._createReadStream(file, options).then(stream => {
|
||||
// detect early errors
|
||||
let promise = eventToPromise(stream, 'readable')
|
||||
let promise = fromEvent(stream, 'readable')
|
||||
|
||||
// try to add the length prop if missing and not a range stream
|
||||
if (
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
import assert from 'assert'
|
||||
import concurrency from 'limit-concurrency-decorator'
|
||||
import eventToPromise from 'event-to-promise'
|
||||
import fu from '@nraynaud/struct-fu'
|
||||
import isEqual from 'lodash/isEqual'
|
||||
import { fromEvent } from 'promise-toolbox'
|
||||
|
||||
import constantStream from './constant-stream'
|
||||
import { noop, streamToBuffer } from './utils'
|
||||
@ -405,7 +405,7 @@ export class Vhd {
|
||||
stream.on('error', reject)
|
||||
stream.end(data, resolve)
|
||||
})
|
||||
: eventToPromise(data.pipe(stream), 'finish')
|
||||
: fromEvent(data.pipe(stream), 'finish')
|
||||
}
|
||||
|
||||
async ensureBatSize (size) {
|
||||
|
@ -1,9 +1,8 @@
|
||||
import deferrable from 'golike-defer'
|
||||
import escapeStringRegexp from 'escape-string-regexp'
|
||||
import eventToPromise from 'event-to-promise'
|
||||
import execa from 'execa'
|
||||
import splitLines from 'split-lines'
|
||||
import { CancelToken, ignoreErrors } from 'promise-toolbox'
|
||||
import { CancelToken, fromEvent, ignoreErrors } from 'promise-toolbox'
|
||||
import { createParser as createPairsParser } from 'parse-pairs'
|
||||
import { createReadStream, readdir, stat } from 'fs'
|
||||
import { satisfies as versionSatisfies } from 'semver'
|
||||
@ -123,7 +122,7 @@ async function checkFileIntegrity (handler, name) {
|
||||
// }
|
||||
//
|
||||
// stream.resume()
|
||||
// await eventToPromise(stream, 'finish')
|
||||
// await fromEvent(stream, 'finish')
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@ -678,7 +677,7 @@ export default class {
|
||||
stream.on('error', error => targetStream.emit('error', error))
|
||||
|
||||
await Promise.all([
|
||||
eventToPromise(stream.pipe(sizeStream).pipe(targetStream), 'finish'),
|
||||
fromEvent(stream.pipe(sizeStream).pipe(targetStream), 'finish'),
|
||||
stream.task,
|
||||
])
|
||||
} catch (error) {
|
||||
@ -935,10 +934,7 @@ export default class {
|
||||
|
||||
sourceStream.pipe(sizeStream).pipe(targetStream)
|
||||
|
||||
await Promise.all([
|
||||
sourceStream.task,
|
||||
eventToPromise(targetStream, 'finish'),
|
||||
])
|
||||
await Promise.all([sourceStream.task, fromEvent(targetStream, 'finish')])
|
||||
|
||||
return {
|
||||
transferSize: sizeStream.size,
|
||||
|
Loading…
Reference in New Issue
Block a user