Remove highland as a dependency.

This commit is contained in:
Bryce Gibson
2023-03-22 20:41:44 +11:00
parent 053712c8d3
commit ec8597c124
3 changed files with 13 additions and 23 deletions
+13 -5
View File
@@ -6,14 +6,19 @@ import { argv } from '../options'
import { File } from 'resolve-dependencies'
import MultiStream = require('multistream')
const archiver: any = require('archiver')
const highland: any = require('highland')
function makeRelativeToZip(cwd: string, path: string) {
return '/snapshot/' + relative(cwd, path)
}
export function toStream(content: Buffer | string) {
return highland([content])
const readable = new Readable({
read() {
this.push(content)
this.push(null)
},
})
return readable
}
export class Bundle {
cwd: string
@@ -42,8 +47,11 @@ export class Bundle {
public async toBuffer(): Promise<Buffer> {
this.zip.finalize()
return await new Promise((resolve) =>
highland(this.zip).toArray((arr: Array<Buffer>) => resolve(Buffer.concat(arr)))
)
const zipData: Buffer[] = []
this.zip.on('data', (data: Buffer) => zipData.push(data))
return await new Promise((resolve, reject) => {
this.zip.on('error', (error: Error) => reject(error))
this.zip.on('end', () => resolve(Buffer.concat(zipData)))
})
}
}