Download any file without blocking your server using the power of curl.
forked from node-CurlDownloader and rewrited in coffee-script.
Install through NPM
npm install curl-download
OR
- Download download.js or download.coffee
- Include in project
# import download
Download = require 'download'
# new download instance
dl = new Download(
'http://code.jquery.com/jquery-1.11.0.min.js',
'tmp/jquery-1.11.0.min.js'
)
# when progress
dl.on 'progress', (progress)->
console.log "#{progress}%"
return
# when end
dl.on 'end', (code)->
# when success
if code == 0
console.log "finished successfully"
# when fail
else
console.log "finished unsuccessfully"
process.exit(code)
return
# start download
dl.start()
var Download, dl;
Download = require('download');
dl = new Download('http://code.jquery.com/jquery-1.11.0.min.js', 'tmp/jquery-1.11.0.min.js');
dl.on('progress', function(progress) {
console.log("" + progress + "%");
});
dl.on('end', function(code) {
if (code === 0) {
console.log("finished successfully");
} else {
console.log("finished unsuccessfully");
}
process.exit(code);
});
dl.start();