UNPKG

download-file

Version:

Generic file download utility

47 lines (35 loc) 754 B
var dl = require('./index.js') var url = "i.imgur.com/G9bDaPH.jpg" var opts = { directory: "./images/cats/", filename: "cat.gif" } dl(url, opts, function(err){ if (err) hiss(err) meow("no protocol") }) var url = "http://i.imgur.com/G9bDaPH.jpg" var opts = { directory: "./images/cats/", filename: "cat.gif" } dl(url, opts, function(err){ if (err) hiss(err) meow("http protocol") }) var url = "http://i.imgur.com/G9bDaPH.jpg" var opts = { directory: "./images/cats/", filename: "cat.gif" } dl(url, opts, function(err){ if (err) hiss(err) meow("https protocol") }) function meow(msg) { console.log("\033[32m", "meow: " + msg, "\033[91m") } function hiss(err) { console.log("\033[31m", "hiss", "\033[91m") throw err }