How to use node-downloader-helper - 2 common examples

To help you get started, we’ve selected a few node-downloader-helper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github evilmartians / lefthook / .npm / install.js View on Github external
async function downloadBinary() {
  // TODO zip the binaries to reduce the download size
  const downloadURL = getDownloadURL()
  const extension = iswin ? ".exe" : ""
  const fileName = `lefthook${extension}`
  const binDir = path.join(__dirname, "bin")
  const dl = new DownloaderHelper(downloadURL, binDir, {
    fileName,
    retry: { maxRetries: 5, delay: 50 },
  })
  dl.on("end", () => console.log("lefthook binary was downloaded"))
  try {
    await dl.start()
  } catch(e) {
    const message = `Failed to download ${fileName}: ${e.message} while fetching ${downloadURL}`
    console.error(message)
    throw new Error(message)
  }
  return path.join(binDir, fileName)
}
github LoliLin / CloudMan / modules / general.js View on Github external
return await new Promise((resolve, reject) => {
        setTimeout(() => reject(new Error('Timeout')), (isPhoto) ? 10000 : 60000)

        const dl = new DownloaderHelper(fileURL, path.resolve(savePath), {
          override: true,
          fileName: filename
        })

        dl.on('error', async (error) => {
          await dl.stop()
          logger.warn(`[Track: ${trackInfo.title}][${msg}]`, error)
          reject(error)
        }).on('timeout', async () => {
          await dl.stop()
        }).on('end', () => {
          logger.debug(`[Track: ${trackInfo.title}][${msg}] Download completed!`)
          resolve()
        })

        dl.start()

node-downloader-helper

A simple http/s file downloader for node.js

MIT
Latest version published 1 year ago

Package Health Score

62 / 100
Full package analysis

Popular node-downloader-helper functions