Skip to content

Instantly share code, notes, and snippets.

@pfrazee
Created June 26, 2017 21:14
Show Gist options
  • Save pfrazee/e5cf70dfd06a8d9f4e25e468b33c748e to your computer and use it in GitHub Desktop.
Save pfrazee/e5cf70dfd06a8d9f4e25e468b33c748e to your computer and use it in GitHub Desktop.
Hyperdrive download error case
const hyperdrive = require('hyperdrive')
const tempy = require('tempy')
const fs = require('fs')
const path = require('path')
const pda = require('pauls-dat-api')
const toZipStream = require('hyperdrive-to-zip-stream')
go()
async function go () {
var archive = hyperdrive(tempy.directory())
await new Promise(archive.ready)
await pda.writeFile(archive, 'hello.txt', 'hello.txt', 'utf8')
await pda.writeFile(archive, 'log.js', 'log.js', 'utf8')
await pda.mkdir(archive, 'dir')
await pda.writeFile(archive, 'dir/hello.txt', 'dir/hello.txt', 'utf8')
var zs = toZipStream(archive)
zs.on('error', console.error)
zs.pipe(fs.createWriteStream(path.join(__dirname, 'out.zip')))
}
{
"name": "undownload-issue",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"hyperdrive": "^9.4.6",
"hyperdrive-to-zip-stream": "^2.0.0",
"pauls-dat-api": "^4.2.4",
"tempy": "^0.1.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment